|
| 1 | +# Releases @reearth/core to the `alpha` dist-tag on npm. |
| 2 | +# |
| 3 | +# Publishing is secured via npm Trusted Publishing (OIDC): no long-lived |
| 4 | +# NPM_TOKEN is used, and every publish carries a provenance attestation |
| 5 | +# (verify with `npm audit signatures`). |
| 6 | +# |
| 7 | +# One-time prerequisite (do this BEFORE the first run on the alpha branch): |
| 8 | +# On npmjs.com: @reearth/core -> Settings -> Trusted publishers -> add |
| 9 | +# Organization/user: reearth |
| 10 | +# Repository: core |
| 11 | +# Workflow filename: release_alpha.yml |
| 12 | +# (Leave environment blank.) This tells npm to accept OIDC tokens minted by |
| 13 | +# this exact workflow instead of an NPM_TOKEN secret. |
| 14 | +# |
| 15 | +# The version bump commit + tag are still pushed to the protected alpha branch |
| 16 | +# using the PAT secret (an account that can push directly to alpha). Only the |
| 17 | +# npm publish step moved to OIDC; the git push credential is unchanged. |
| 18 | +# |
| 19 | +# beta/latest still publish via npm_release.yml + NPM_TOKEN and are unaffected. |
| 20 | + |
| 21 | +name: Release Alpha |
| 22 | + |
1 | 23 | on: |
2 | 24 | push: |
3 | 25 | branches: alpha |
4 | 26 | paths-ignore: |
5 | 27 | - "package.json" |
6 | 28 | workflow_dispatch: |
7 | 29 |
|
| 30 | +permissions: |
| 31 | + contents: write # push the version bump commit + tag |
| 32 | + id-token: write # mint the OIDC token for npm Trusted Publishing + provenance |
| 33 | + |
8 | 34 | jobs: |
9 | 35 | release: |
10 | | - permissions: |
11 | | - contents: write |
12 | | - uses: reearth/core/.github/workflows/npm_release.yml@beta |
13 | | - with: |
14 | | - branch: alpha |
15 | | - tag: alpha |
16 | | - version-args: --preid alpha prerelease |
17 | | - secrets: |
18 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
19 | | - PAT: ${{ secrets.PAT }} |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + # PAT (not GITHUB_TOKEN) so the bump commit/tag can be pushed |
| 41 | + # directly to the protected alpha branch. |
| 42 | + token: ${{ secrets.PAT }} |
| 43 | + - uses: actions/setup-node@v4 |
| 44 | + with: |
| 45 | + # Trusted Publishing requires Node >=22.14 and npm >=11.5.1. |
| 46 | + node-version: 22 |
| 47 | + registry-url: "https://registry.npmjs.org" |
| 48 | + - name: Activate npm via corepack |
| 49 | + # Node 22 ships npm 10.x; Trusted Publishing needs >=11.5.1. corepack |
| 50 | + # fetches a fresh npm binary directly, avoiding the broken self-upgrade |
| 51 | + # path in the bundled npm 10.x. |
| 52 | + run: | |
| 53 | + corepack enable npm |
| 54 | + corepack prepare npm@11.5.1 --activate |
| 55 | + npm --version |
| 56 | + - name: Get yarn cache directory path |
| 57 | + id: yarn-cache-dir-path |
| 58 | + run: echo "path=$(yarn cache dir)" >> $GITHUB_OUTPUT |
| 59 | + - uses: actions/cache@v4 |
| 60 | + with: |
| 61 | + path: ${{ steps.yarn-cache-dir-path.outputs.path }} |
| 62 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-yarn- |
| 65 | + - name: Run install |
| 66 | + run: yarn install --frozen-lockfile |
| 67 | + - name: Set up github actions user |
| 68 | + run: | |
| 69 | + git config --global user.name "keiya01" |
| 70 | + git config --global user.email "34934510+keiya01@users.noreply.github.com" |
| 71 | + - name: Run npm version |
| 72 | + # Triggers the preversion (yarn test run) and version (yarn build) npm |
| 73 | + # scripts, so the package is tested and built before publish. |
| 74 | + run: npm version --preid alpha prerelease |
| 75 | + - name: Git push |
| 76 | + run: | |
| 77 | + git push origin alpha |
| 78 | + git push --tags |
| 79 | + - name: Publish to npm with provenance (OIDC) |
| 80 | + # No NPM_TOKEN: auth is via the OIDC handshake configured as a Trusted |
| 81 | + # Publisher on npmjs.com. --access public because @reearth/core is scoped. |
| 82 | + run: npm publish --provenance --access public --tag alpha |
0 commit comments