Skip to content

Commit f08ea1d

Browse files
fix(ci): npm release artifact (#241)
While componentize-js packages can be now automatically released, the packages that come out of the build are missing generated files and GHA attestations don't look like they're being recognized by NPM. After "local" testing (via another repo), this commit addresses all the issues with the current release CI step. This commit: - uses package-lock.json for runner cache - removes a redundant release build - enables attestation publishing for NPM - uses more direct artifact name - requires node version >= 22.x
1 parent 9d86d89 commit f08ea1d

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
id: cache-node-modules
4545
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4646
with:
47-
key: node-modules-dev-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
47+
key: node-modules-dev-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
4848
path: |
4949
node_modules
5050
- name: Install debug NPM packages
@@ -102,9 +102,6 @@ jobs:
102102
runs-on: ubuntu-24.04
103103
needs:
104104
- meta
105-
permissions:
106-
id-token: write
107-
attestations: write
108105
strategy:
109106
matrix:
110107
rust-version:
@@ -133,33 +130,24 @@ jobs:
133130
- name: Cache npm install
134131
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
135132
with:
136-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
133+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
137134
path: |
138135
node_modules
139136
140137
- name: Install NPM packages
141138
run: |
142139
npm install
143140
144-
- name: Perform release build
145-
run: |
146-
npm run build:release
147-
148141
- name: Create release package
149142
working-directory: ${{ needs.meta.outputs.project-dir }}
150143
run: |
151144
npm pack
152145
153-
- uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
154-
with:
155-
subject-path: ${{ needs.meta.outputs.artifacts-glob }}
156-
157146
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
158147
with:
159148
if-no-files-found: error
160-
name: componentize-js
161149
path: |
162-
${{ needs.meta.outputs.artifacts-glob }}
150+
${{ needs.meta.outputs.artifact-name }}
163151
164152
test-npm-release:
165153
runs-on: ubuntu-24.04
@@ -176,22 +164,28 @@ jobs:
176164
- name: Test built componentize-js NPM package
177165
shell: bash
178166
run: |
179-
export PACKAGE_DIR=${{ github.workspace }}/artifacts/componentize-js/${{ needs.meta.outputs.artifact-name }}
167+
export PACKAGE_FILE_PATH=${{ github.workspace }}/artifacts/artifact/${{ needs.meta.outputs.artifact-name }}
180168
cp -r examples/hello-world/guest /tmp/test
181169
cd /tmp/test
182-
npm install --save $PACKAGE_DIR
170+
npm install --save $PACKAGE_FILE_PATH
183171
npm run all
184172
185173
npm-publish:
186174
runs-on: ubuntu-24.04
187175
needs:
188176
- meta
189177
- test-npm-release
178+
permissions:
179+
id-token: write
190180
env:
191181
PREPACK_SKIP_BUILD: "true"
192182
steps:
193183
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
194184

185+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
186+
with:
187+
node-version: ">=22"
188+
195189
- name: Add npmrc
196190
run: |
197191
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
@@ -205,7 +199,7 @@ jobs:
205199
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
206200
shell: bash
207201
run: |
208-
export PACKAGE_DIR=${{ github.workspace }}/artifacts/componentize-js/${{ needs.meta.outputs.artifact-name }}
202+
export PACKAGE_FILE_PATH=${{ github.workspace }}/artifacts/artifact/${{ needs.meta.outputs.artifact-name }}
209203
210204
export OPT_DRY_RUN="--dry-run"
211205
if [ "tag" == "${{ github.ref_type }}" ]; then
@@ -217,7 +211,14 @@ jobs:
217211
export OPT_RELEASE_TAG="--tag ${{ needs.meta.outputs.prerelease-tag }}";
218212
fi
219213
220-
npm publish -w @bytecodealliance/componentize-js $OPT_DRY_RUN $OPT_RELEASE_TAG $PACKAGE_DIR --access=public
214+
npm publish \
215+
--verbose \
216+
-w @bytecodealliance/componentize-js \
217+
--access=public \
218+
--provenance \
219+
$OPT_DRY_RUN \
220+
$OPT_RELEASE_TAG \
221+
$PACKAGE_FILE_PATH
221222
222223
create-gh-release:
223224
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)