-
Notifications
You must be signed in to change notification settings - Fork 47
137 lines (118 loc) · 5.08 KB
/
create-release-pr.yml
File metadata and controls
137 lines (118 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: create-release-pr
run-name: create-release-pr
description: |
Create a release PR for a project in the repository
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: |
Version to prep for release (ex. `0.1.0`, `0.1.0-rc.0`)
permissions:
contents: none
jobs:
create-release-pr:
runs-on: ubuntu-24.04
permissions:
id-token: write
pull-requests: write
contents: write
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
# Install Rust deps
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- uses: taiki-e/cache-cargo-install-action@5c9abe9a3f79d831011df7c47177debbeb320405 # v2.1.2
with:
tool: git-cliff
- name: Cache npm install
id: cache-node-modules
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-dev-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install debug NPM packages
run: |
npm install -D
- name: Gather project metadata
id: project-meta
env:
NEXT_VERSION: ${{ inputs.version }}
shell: bash
run: |
if [[ $NEXT_VERSION == v* ]]; then
echo "::error::next version [$NEXT_VERSION] starts with 'v' -- enter only the semver version (ex. '0.1.0', not 'v0.1.0')";
exit 1;
fi
export PROJECT_DIR=$PWD;
export CURRENT_VERSION=$(node -e "process.stdout.write(require(process.env.PROJECT_DIR + '/package.json').version)");
echo -e "project-dir=$PROJECT_DIR"
echo -e "current-version=$CURRENT_VERSION"
echo -e "next-version=$NEXT_VERSION"
echo -e "project-dir=$PROJECT_DIR" >> $GITHUB_OUTPUT
echo -e "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo -e "next-version=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Ensure next version is after current
run: |
IS_AFTER=$(node scripts/semver-lt.mjs ${{ steps.project-meta.outputs.current-version }} ${{ steps.project-meta.outputs.next-version }});
if [ "$IS_AFTER" == "false" ]; then \
echo "::error::project [componentize-js] next version [${{ steps.project-meta.outputs.next-version }}] is not after current version [${{ steps.project-meta.outputs.current-version }}]";
exit 1;
fi
# Set project version
- name: Set project version
working-directory: ${{ steps.project-meta.outputs.project-dir }}
shell: bash
run: |
npm pkg set version=${{ steps.project-meta.outputs.next-version }};
sed -i \
"s/version('${{ steps.project-meta.outputs.current-version }}')/version('${{ steps.project-meta.outputs.next-version }}')/" \
src/cli.js;
# Generate changelog
#
# NOTE: we use the 'latest' tag here, because starting from an rc/alpha/beta release
# the rc/alpha/beta release tags are ignored and the "latest" tag is the previous stable version
- name: Generate changelog
working-directory: ${{ steps.project-meta.outputs.project-dir }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
run: |
export IS_PRERELEASE=$(node scripts/semver-is-prerelease.mjs ${{ steps.project-meta.outputs.next-version }});
export OPT_TAG=--tag=${{ steps.project-meta.outputs.next-version }};
export OPT_TAG_PATTERN=--tag-pattern='^[0-9]+.[0-9]+.[0-9]+$';
if [ "true" == "$IS_PRERELEASE" ]; then
export OPT_TAG_PATTERN=--tag-pattern='^[0-9]+.[0-9]+.[0-9]+(-beta|-rc|-alpha)?';
fi
git cliff \
--repository=${{ github.workspace }}/.git \
--config=./cliff.toml \
--unreleased \
$OPT_TAG \
$OPT_TAG_PATTERN \
--prepend=CHANGELOG.md
# Create release PR
- name: Create release prep PR
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
branch: prep-release-v${{ steps.project-meta.outputs.next-version }}
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
commit-message: |
release: componentize-js v${{ steps.project-meta.outputs.next-version }}
title: |
release: componentize-js v${{ steps.project-meta.outputs.next-version }}
labels: |
release-pr
assignees: >-
vados-cosmonic,
tschneidereit
signoff: true
body: |
This is a release prep branch for `componentize-js` release `v${{ steps.project-meta.outputs.next-version }}`.
To ensure this release is ready to be merged:
- [ ] Review updated CHANGELOG(s)
After this PR is merged tagging, artifact builds and releasing will run automatically.