From 018c609016a7637a7223bef5df1c987c41cd36a8 Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Wed, 12 Aug 2026 22:00:27 +0200 Subject: [PATCH] Migrate CI to OIDC trusted publishing --- .github/workflows/engine-publish.yml | 22 ++++++++++++---------- .github/workflows/viewer-publish.yml | 25 ++++++++++++++++--------- .husky/pre-commit | 9 ++++++++- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/.github/workflows/engine-publish.yml b/.github/workflows/engine-publish.yml index 815ef65..1f9ca03 100644 --- a/.github/workflows/engine-publish.yml +++ b/.github/workflows/engine-publish.yml @@ -8,7 +8,7 @@ on: default: patch env: - node_version: 14 + node_version: 24 defaults: run: @@ -17,24 +17,26 @@ defaults: jobs: version_and_release: runs-on: ubuntu-latest + permissions: + contents: write # git push --follow-tags + id-token: write # OIDC trusted publishing steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ env.node_version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: 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' - - uses: pnpm/action-setup@v1.2.1 - with: - version: 5.17.1 + - run: npm install -g pnpm@5.17.1 - run: pnpm install - run: git config --global user.name github-actions - run: git config --global user.email bot@github.com - run: yarn config set version-git-message "Engine v%s" - run: yarn version --${{ github.event.inputs.newversion }} - run: sed -i 's:container-engine:@boardgamers/container-engine:' package.json - - run: pnpm publish --access public --no-git-checks . - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # pnpm 10.16+ supports OIDC trusted publishing; publish via npx so we don't have to bump + # the repo-wide pnpm. No NODE_AUTH_TOKEN is set, so publishing authenticates with the + # 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 diff --git a/.github/workflows/viewer-publish.yml b/.github/workflows/viewer-publish.yml index 07c13fa..1306dd4 100644 --- a/.github/workflows/viewer-publish.yml +++ b/.github/workflows/viewer-publish.yml @@ -8,7 +8,7 @@ on: default: patch env: - node_version: 14 + node_version: 24 defaults: run: @@ -17,24 +17,31 @@ defaults: jobs: version_and_release: runs-on: ubuntu-latest + permissions: + contents: write # git push --follow-tags + id-token: write # OIDC trusted publishing steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ env.node_version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: 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' - - uses: pnpm/action-setup@v1.2.1 - with: - version: 5.17.1 + - run: npm install -g pnpm@5.17.1 - run: pnpm install - run: git config --global user.name github-actions - run: git config --global user.email bot@github.com - run: yarn config set version-git-message "Viewer v%s" - run: yarn version --${{ github.event.inputs.newversion }} - 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: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_OPTIONS: --openssl-legacy-provider - run: git push --follow-tags diff --git a/.husky/pre-commit b/.husky/pre-commit index 79fde57..ea5f095 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,11 @@ #!/bin/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