Skip to content

Commit a233087

Browse files
authored
refactor: switched to trusted publishing (#731)
* Revert "refactor: revert previous tries (#727)" This reverts commit e37b639. * Add permissions for contents in publish workflow * Add permissions for contents in publish workflow * Modify permissions in publish.yml Updated permissions for the publish workflow. * Add npm whoami command before publishing * Update tag extraction method in publish workflow * Update 02-publish.yml * Remove npm whoami from publish step Remove npm whoami command from publish workflow * Display npm version before publishing to npm Added echo command to display npm version before publishing. * Update 02-publish.yml * Update 02-publish.yml * Add PNPM initialization step in workflow * Update 02-publish.yml * Update 00-init.yml * Update 00-init.yml * Update 02-publish.yml * Update publish.yml * Update 02-publish.yml * Update 02-publish.yml * Update npm publish command in workflow Remove provenance flag from npm publish command. This is automatically enabled when using trusted publishing. * Update publish.yml * Update 02-publish.yml
1 parent 5348eb4 commit a233087

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.github/workflows/02-publish.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
- name: 🔄 Init PNPM
1818
uses: ./.github/actions/pnpm-init
1919

20+
- name: Setup Node.js
21+
uses: actions/setup-node@v5
22+
with:
23+
node-version-file: ".nvmrc"
24+
2025
- name: ⏬ Download dist
2126
uses: actions/download-artifact@v5
2227
with:
@@ -25,16 +30,18 @@ jobs:
2530

2631
- name: 🔀 Extract tag
2732
shell: bash
28-
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
33+
run: echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
2934
id: extractTag
3035

3136
- name: 🔜 Publish to npm
3237
env:
3338
TAG: ${{ steps.extractTag.outputs.tag }}
34-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
NPM_TAG: ${{ github.event.release.prerelease && 'next' || 'latest' }}
3540
run: |
41+
echo "node, npm and release version:"
42+
node -v
43+
npm -v
3644
SEMVER_VERSION=$(npx find-versions-cli "$TAG")
3745
npm version --no-git-tag-version "$SEMVER_VERSION"
3846
npm config set registry https://registry.npmjs.org/
39-
npm set //registry.npmjs.org/:_authToken "$NPM_TOKEN"
40-
npm publish --provenance
47+
npm publish --tag $NPM_TAG

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
needs: [build, lint, test]
2929
secrets: inherit
3030
permissions:
31-
id-token: write
31+
id-token: write # Required for OIDC

0 commit comments

Comments
 (0)