diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d29d2b..314d6ea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,18 +5,23 @@ name: release # It typechecks, tests, builds, and publishes `meshy-cli` plus its scoped alias # `@meshy-ai/cli` at whatever version package.json currently declares. # -# One-time setup: an npm automation token with publish rights on `meshy-cli` -# and the `@meshy-ai` scope, stored as the `NPM_TOKEN` secret. +# No npm token is stored anywhere: both packages publish through npm trusted +# publishing (GitHub OIDC), with provenance. On npmjs.com each package trusts +# meshy-dev/meshy-cli, this workflow file (release.yml) and the `release` +# environment, which only `main` may deploy to. Renaming the file or the +# environment breaks publishing until both npm settings are recreated. on: workflow_dispatch: permissions: contents: read + id-token: write jobs: publish: runs-on: ubuntu-latest + environment: release steps: - uses: actions/checkout@v7 @@ -38,9 +43,12 @@ jobs: run: | test "$(node dist/index.js --version)" = "$(node -p "require('./package.json').version")" + # Trusted publishing needs npm 11.5.1 or newer. + - run: npm install -g npm@^11.5.1 + # Both publish steps skip versions that already exist on the registry, # so re-running the workflow after a half-published release (e.g. the - # unscoped package went out but the alias failed on scope/token setup) + # unscoped package went out but the alias failed on its npm setup) # resumes at the missing package instead of erroring on the first. - name: Publish meshy-cli run: | @@ -50,8 +58,6 @@ jobs: else npm publish --access public fi - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Publish scoped alias @meshy-ai/cli (same version) run: | @@ -62,5 +68,3 @@ jobs: else npm publish --access public fi - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}