Migrate CI to OIDC trusted publishing

This commit is contained in:
coyotte508 2026-08-12 22:00:27 +02:00
commit 018c609016
3 changed files with 36 additions and 20 deletions

View file

@ -8,7 +8,7 @@ on:
default: patch default: patch
env: env:
node_version: 14 node_version: 24
defaults: defaults:
run: run:
@ -17,24 +17,26 @@ defaults:
jobs: jobs:
version_and_release: version_and_release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write # git push --follow-tags
id-token: write # OIDC trusted publishing
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Use Node.js ${{ env.node_version }} - name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v2 uses: actions/setup-node@v4
with: with:
node-version: ${{ env.node_version }} node-version: ${{ env.node_version }}
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED # registry-url is required so npm publish targets the public npm registry
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v1.2.1 - run: npm install -g pnpm@5.17.1
with:
version: 5.17.1
- run: pnpm install - run: pnpm install
- run: git config --global user.name github-actions - run: git config --global user.name github-actions
- run: git config --global user.email bot@github.com - run: git config --global user.email bot@github.com
- run: yarn config set version-git-message "Engine v%s" - run: yarn config set version-git-message "Engine v%s"
- run: yarn version --${{ github.event.inputs.newversion }} - run: yarn version --${{ github.event.inputs.newversion }}
- run: sed -i 's:container-engine:@boardgamers/container-engine:' package.json - run: sed -i 's:container-engine:@boardgamers/container-engine:' package.json
- run: pnpm publish --access public --no-git-checks . # pnpm 10.16+ supports OIDC trusted publishing; publish via npx so we don't have to bump
env: # the repo-wide pnpm. No NODE_AUTH_TOKEN is set, so publishing authenticates with the
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # OIDC token instead of the (now-rejected) npm token.
- run: npx -y pnpm@latest publish . --access public --no-git-checks
- run: git push --follow-tags - run: git push --follow-tags

View file

@ -8,7 +8,7 @@ on:
default: patch default: patch
env: env:
node_version: 14 node_version: 24
defaults: defaults:
run: run:
@ -17,24 +17,31 @@ defaults:
jobs: jobs:
version_and_release: version_and_release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write # git push --follow-tags
id-token: write # OIDC trusted publishing
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Use Node.js ${{ env.node_version }} - name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v2 uses: actions/setup-node@v4
with: with:
node-version: ${{ env.node_version }} node-version: ${{ env.node_version }}
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED # registry-url is required so npm publish targets the public npm registry
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v1.2.1 - run: npm install -g pnpm@5.17.1
with:
version: 5.17.1
- run: pnpm install - run: pnpm install
- run: git config --global user.name github-actions - run: git config --global user.name github-actions
- run: git config --global user.email bot@github.com - run: git config --global user.email bot@github.com
- run: yarn config set version-git-message "Viewer v%s" - run: yarn config set version-git-message "Viewer v%s"
- run: yarn version --${{ github.event.inputs.newversion }} - run: yarn version --${{ github.event.inputs.newversion }}
- run: sed -i 's:"container-viewer":"@boardgamers/container-viewer":' package.json - run: sed -i 's:"container-viewer":"@boardgamers/container-viewer":' package.json
- run: pnpm publish --access public --no-git-checks . # pnpm 10.16+ supports OIDC trusted publishing and rewrites the workspace:../engine
# dependency to a real version range; publish via npx so we don't have to bump the
# repo-wide pnpm (which would force a lockfile rewrite). No NODE_AUTH_TOKEN is set, so
# publishing authenticates with the OIDC token instead of the (now-rejected) npm token.
# NODE_OPTIONS=--openssl-legacy-provider works around webpack 4 (vue-cli-service) relying
# on MD4, which OpenSSL 3 (bundled with Node >= 17) no longer supports out of the box.
- run: npx -y pnpm@latest publish . --access public --no-git-checks
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_OPTIONS: --openssl-legacy-provider
- run: git push --follow-tags - run: git push --follow-tags

View file

@ -1,4 +1,11 @@
#!/bin/sh #!/bin/sh
. "$(dirname "$0")/_/husky.sh" . "$(dirname "$0")/_/husky.sh"
pnpm run lint-staged # The system pnpm is a corepack shim running pnpm 11, which fails on this repo's
# old (v5) lockfile. Prefer a repo-local pnpm 5 if one is installed.
PNPM="$(git rev-parse --git-dir)/pnpm-local.sh"
if [ ! -x "$PNPM" ]; then
PNPM="pnpm"
fi
"$PNPM" run lint-staged