-
Notifications
You must be signed in to change notification settings - Fork 47
282 lines (245 loc) · 9.79 KB
/
release.yml
File metadata and controls
282 lines (245 loc) · 9.79 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: release
run-name: release
on:
push:
# NOTE: pushes from CI without a PAT will not trigger the tags below
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
- "[0-9]+.[0-9]+.[0-9]+-*"
branches:
- "prep-release-v[0-9]+.[0-9]+.[0-9]+*"
- "prep-release-v[0-9]+.[0-9]+.[0-9]+-*"
workflow_dispatch:
inputs:
version:
type: string
required: true
description: |
Version tag to release (e.x. `0.1.0`, `0.2.0`)
permissions:
contents: none
jobs:
meta:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.meta.outputs.version }}
project-dir: ${{ steps.project-meta.outputs.project-dir }}
artifacts-glob: ${{ steps.project-meta.outputs.artifacts-glob }}
artifact-name: ${{ steps.project-meta.outputs.artifact-name }}
next-release-tag: ${{ steps.project-meta.outputs.next-release-tag }}
is-prerelease: ${{ steps.project-meta.outputs.is-prerelease }}
prerelease-tag: ${{ steps.project-meta.outputs.prerelease-tag }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: ">=22"
- 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-lock.json') }}
path: |
node_modules
- name: Install debug NPM packages
run: |
npm install -D
- name: Collect metadata
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: meta
with:
script: |
if (context.payload.inputs?.version) {
core.setOutput('version', context.payload.inputs.version);
return;
}
if (context.ref.startsWith('refs/tags/')) {
match = context.ref.replace('refs/tags/', '').match(/^([^\s]+)$/);
} else if (context.ref.startsWith('refs/heads/')) {
match = context.ref.replace('refs/heads/', '').match(/^prep-release-v([^\s]+)$/);
} else {
throw new Error(`Unexpected context ref [${context.ref}]`);
}
if (!match) { throw new Error(`Failed to parse tag/branch: [${context.ref}]`); }
const [_, version] = match;
core.setOutput('version', version);
- name: Gather project metadata
id: project-meta
env:
NEXT_VERSION: ${{ steps.meta.outputs.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)");
export ARTIFACTS_GLOB="bytecodealliance-componentize-js-*.tgz";
export ARTIFACT_NAME="bytecodealliance-componentize-js-$NEXT_VERSION.tgz";
echo -e "project-dir=$PROJECT_DIR" >> $GITHUB_OUTPUT;
echo -e "artifacts-glob=$ARTIFACTS_GLOB" >> $GITHUB_OUTPUT;
echo -e "artifact-name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT;
echo -e "next-release-tag=${NEXT_VERSION}" >> $GITHUB_OUTPUT;
export IS_PRERELEASE=$(node scripts/semver-is-prerelease.mjs $NEXT_VERSION);
echo -e "is-prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT;
export PRERELEASE_TAG=$(node scripts/semver-get-prerelease.mjs $NEXT_VERSION);
echo -e "prerelease-tag=$PRERELEASE_TAG" >> $GITHUB_OUTPUT;
pack-npm-release:
runs-on: ubuntu-24.04
needs:
- meta
strategy:
matrix:
rust-version:
- stable
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- name: Get StarlingMonkey Commit
id: starlingmonkey-commit
run: echo "STARLINGMONKEY_HASH=$(git submodule status | head -c9 | tail -c8)" >> "$GITHUB_OUTPUT"
- name: Install Rust Toolchain
run: |
rustup toolchain install ${{ matrix.rust-version }}
rustup target add wasm32-wasip1 --toolchain ${{ matrix.rust-version }}
rustup target add wasm32-wasip1
# NOTE: we must use a node version new-enough to have --experimental-wasm-jspi
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: ">=22"
- name: Cache npm install
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Install NPM packages
run: |
npm install
- name: Create release package
working-directory: ${{ needs.meta.outputs.project-dir }}
run: |
npm pack
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
if-no-files-found: error
path: |
${{ needs.meta.outputs.artifact-name }}
test-npm-release:
runs-on: ubuntu-24.04
needs:
- meta
- pack-npm-release
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: artifacts
- name: Test built componentize-js NPM package
shell: bash
run: |
export PACKAGE_FILE_PATH=${{ github.workspace }}/artifacts/artifact/${{ needs.meta.outputs.artifact-name }}
cp -r examples/hello-world/guest /tmp/test
cd /tmp/test
npm install --save $PACKAGE_FILE_PATH
npm run all
npm-publish:
runs-on: ubuntu-24.04
needs:
- meta
- test-npm-release
permissions:
id-token: write
env:
PREPACK_SKIP_BUILD: "true"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: ">=24"
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: artifacts
- name: Publish componentize-js to NPM
shell: bash
run: |
export PACKAGE_FILE_PATH=${{ github.workspace }}/artifacts/artifact/${{ needs.meta.outputs.artifact-name }}
export OPT_DRY_RUN="--dry-run"
if [ "tag" == "${{ github.ref_type }}" ]; then
export OPT_DRY_RUN="";
fi
export OPT_RELEASE_TAG=""
if [ "true" == "${{ needs.meta.outputs.is-prerelease }}" ]; then
export OPT_RELEASE_TAG="--tag ${{ needs.meta.outputs.prerelease-tag }}";
fi
npm publish \
--verbose \
-w @bytecodealliance/componentize-js \
--access=public \
--provenance \
$OPT_DRY_RUN \
$OPT_RELEASE_TAG \
$PACKAGE_FILE_PATH
create-gh-release:
runs-on: ubuntu-24.04
if: always()
needs:
- meta
- test-npm-release
- npm-publish
permissions:
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: taiki-e/install-action@2cab843126c0d8cf950bf55f4e9b8413f70f553f # v2.54.1
with:
fallback: none
tool: git-cliff
# Re-generate the current changelog so we can use it in the GH release announcement
#
# NOTE: if this workflow is being run due to a tag push, that's an *already committed* release
# tag and likely the one corresponding to this release, so we use the latest
#
- name: Re-generate current changelog
working-directory: ${{ needs.meta.outputs.project-dir }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: |
export OPT_START=--unreleased;
export OPT_TAG=;
if [ "tag" == "${{ github.ref_type }}" ]; then
export OPT_START=--current;
export OPT_TAG=--tag=${{ needs.meta.outputs.next-release-tag }};
fi
export OPT_TAG_PATTERN=--tag-pattern='^[0-9]+.[0-9]+.[0-9]+$';
if [ "true" == "${{ needs.meta.outputs.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 \
$OPT_START \
$OPT_TAG \
$OPT_TAG_PATTERN \
> CHANGELOG.current;
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: artifacts
- name: Create GH release
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
with:
token: ${{ secrets.RELEASE_PAT || github.token }}
prerelease: ${{ github.ref_type != 'tag' || needs.meta.outputs.is-prerelease == 'true' }}
draft: ${{ github.ref_type != 'tag' }}
tag_name: ${{ needs.meta.outputs.next-release-tag }}
generate_release_notes: false
make_latest: ${{ github.ref_type == 'tag' && needs.meta.outputs.is-prerelease == 'false' }}
body_path: ${{ needs.meta.outputs.project-dir }}/CHANGELOG.current
files: |
./artifacts/*/*