Skip to content

Commit f8c68f0

Browse files
committed
chore: switch to npm trusted publishing (OIDC) for releases
- Add id-token: write permission for OIDC token minting - Replace bun publish with npm publish --provenance --access public - Add actions/setup-node@v5 with registry-url before publish step - Move GitHub Release/tag creation after publish to avoid orphaned tags - Fix repository URL casing to match GitHub (Zendrex, not zendrex)
1 parent a9cc051 commit f8c68f0

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
permissions:
1616
contents: write
1717
pull-requests: write
18+
id-token: write
1819
steps:
1920
- uses: actions/checkout@v4
2021
- uses: ./.github/actions/ci-setup
@@ -31,32 +32,41 @@ jobs:
3132
env:
3233
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3334

34-
- name: Create GitHub Release
35-
id: github-release
35+
- name: Check if release needed
36+
id: check-release
3637
if: steps.changesets.outputs.hasChangesets == 'false'
3738
run: |
3839
VERSION=$(jq -r '.version' package.json)
3940
TAG="v${VERSION}"
4041
4142
if git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then
4243
echo "Tag $TAG already exists on remote, skipping"
43-
echo "released=false" >> "$GITHUB_OUTPUT"
44-
exit 0
44+
echo "should-release=false" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "should-release=true" >> "$GITHUB_OUTPUT"
47+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
4548
fi
4649
47-
git tag "$TAG"
48-
git push origin "$TAG"
49-
gh release create "$TAG" --generate-notes --title "$TAG"
50-
echo "released=true" >> "$GITHUB_OUTPUT"
51-
env:
52-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53-
5450
- name: Build
55-
if: steps.github-release.outputs.released == 'true'
51+
if: steps.check-release.outputs.should-release == 'true'
5652
run: bun run build
5753

54+
- uses: actions/setup-node@v5
55+
if: steps.check-release.outputs.should-release == 'true'
56+
with:
57+
node-version: lts/*
58+
registry-url: https://registry.npmjs.org
59+
5860
- name: Publish to npm
59-
if: steps.github-release.outputs.released == 'true'
60-
run: bun publish --access public --ignore-scripts
61+
if: steps.check-release.outputs.should-release == 'true'
62+
run: npm publish --provenance --access public
63+
64+
- name: Create GitHub Release
65+
if: steps.check-release.outputs.should-release == 'true'
66+
run: |
67+
TAG="${{ steps.check-release.outputs.tag }}"
68+
git tag "$TAG"
69+
git push origin "$TAG"
70+
gh release create "$TAG" --generate-notes --title "$TAG"
6171
env:
62-
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
},
6363
"repository": {
6464
"type": "git",
65-
"url": "git+https://github.com/zendrex/annotate.git"
65+
"url": "git+https://github.com/Zendrex/annotate.git"
6666
},
6767
"bugs": {
68-
"url": "https://github.com/zendrex/annotate/issues"
68+
"url": "https://github.com/Zendrex/annotate/issues"
6969
},
70-
"homepage": "https://github.com/zendrex/annotate#readme",
70+
"homepage": "https://github.com/Zendrex/annotate#readme",
7171
"keywords": [
7272
"typescript",
7373
"decorators",

0 commit comments

Comments
 (0)