Skip to content

Commit 239e171

Browse files
committed
Restore release-based workflow with Trusted Publishing
1 parent 6ccd84c commit 239e171

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

.github/workflows/publish.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
name: Publish Package
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
release:
5+
types:
6+
- published
77

88
permissions:
99
id-token: write # Required for OIDC
1010
contents: read
1111

1212
jobs:
1313
publish:
14+
if: ${{ github.event.release.prerelease == false }}
1415
runs-on: ubuntu-latest
1516
steps:
1617
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
1720

1821
- uses: actions/setup-node@v4
1922
with:
@@ -26,14 +29,22 @@ jobs:
2629

2730
- run: npm ci
2831

29-
- name: Extract version from tag
30-
id: version
32+
- name: Derive release version
33+
id: release_version
34+
env:
35+
RELEASE_TAG: ${{ github.event.release.tag_name }}
3136
run: |
32-
VERSION=${GITHUB_REF#refs/tags/v}
33-
echo "version=$VERSION" >> $GITHUB_OUTPUT
34-
35-
- name: Update package version
36-
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version
37+
VERSION="${RELEASE_TAG#refs/tags/}"
38+
VERSION="${VERSION#v}"
39+
if [[ -z "$VERSION" ]]; then
40+
echo "Unable to determine version from release tag '${RELEASE_TAG}'" >&2
41+
exit 1
42+
fi
43+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
44+
45+
- name: Sync package metadata
46+
run: |
47+
npm version "${{ steps.release_version.outputs.version }}" --no-git-tag-version
3748
3849
- run: npm run build --if-present
3950
- run: npm publish --access public

0 commit comments

Comments
 (0)