Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish package on NPM

permissions:
contents: write
id-token: write # Required for OIDC trusted publishing
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, GitHub Actions can't generate the OIDC token that npm needs


on:
release:
Expand All @@ -15,9 +16,10 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub will force Node 24 in June 2026 so I took the opportunity to bump the version

with:
node-version: 18
node-version: 24
registry-url: 'https://registry.npmjs.org'
- name: Releasing tag ${{ github.event.release.tag_name }}
run: |
corepack enable; yarn
Expand All @@ -29,24 +31,10 @@ jobs:
cd $(echo $tag_name | rev | cut -d'/' -f2- | rev)
fi

yarn_major_version=$(yarn --version | cut -d'.' -f1)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm publish is the only officially supported path for OIDC trusted publishing.

if [ "$yarn_major_version" -ge 2 ] && [ "$yarn_major_version" -le 4 ]; then
cmd="yarn npm publish --access public"
elif [ "$yarn_major_version" -eq 1 ]; then
cmd="yarn publish --access public"
else
echo "Unsupported Yarn version: $yarn_major_version"
exit 1
fi

if [ "${{ github.event.release.prerelease }}" == "true" ]; then
cmd+=" --tag=beta"
npm publish --provenance --access public --tag beta
else
cmd+=" --tag=latest"
npm publish --provenance --access public --tag latest
fi

eval $cmd
env:
NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }}
YARN_NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }}
COREPACK_ENABLE_DOWNLOAD_PROMPT: 0
Loading