Skip to content

Commit c91170c

Browse files
committed
tidy #24 [CI] Publish the npm package on tags via trusted publishing (Kocal)
This PR was merged into the main branch. Discussion ---------- [CI] Publish the npm package on tags via trusted publishing | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Adds a `Release on NPM` workflow that publishes ``@symfony`/reprise` to npm when a `v*.*.*` tag is pushed. It's modeled closely on the battle-tested `symfony/ux` workflow. - **Trusted publishing (OIDC)**: no `NPM_TOKEN`, just `id-token: write`. npm generates provenance automatically. Requires the package's trusted publisher to be configured on npmjs.com to point at this repo and the `release-on-npm.yaml` workflow. - **Guardrails from symfony/ux**: pinned action SHAs, `persist-credentials: false`, a pinned `npm@11.16.0` (OIDC needs >= 11.5.1), `pnpm install --frozen-lockfile`, and `pnpm publish --recursive --access public --no-git-checks --provenance`. - **Adapted for Reprise**: the tag pattern is `v*.*.*`, the "tag is on a release branch" check targets `main` (Reprise has no `X.x` branches), and there's no committed-dist verification step -- Reprise gitignores `assets/dist` and builds it in CI, so there's nothing committed to diff against. `--recursive` only reaches ``@symfony`/reprise`: the monorepo root and the `playground` package are both `private`. Commits ------- 904959b [CI] Publish the npm package on tags via trusted publishing
2 parents b4234fd + 904959b commit c91170c

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release on NPM
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
11+
12+
concurrency:
13+
group: release-on-npm-${{ github.ref_name }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
21+
with:
22+
ref: ${{ github.ref }}
23+
persist-credentials: false
24+
fetch-depth: 0
25+
26+
- name: Verify tag is on the main branch
27+
run: |
28+
set -euo pipefail
29+
git fetch --no-tags origin refs/heads/main:refs/remotes/origin/main
30+
if ! git merge-base --is-ancestor "${GITHUB_SHA}" refs/remotes/origin/main; then
31+
echo "::error::Tag ${GITHUB_REF_NAME} (${GITHUB_SHA}) is not an ancestor of main. Refusing to publish."
32+
exit 1
33+
fi
34+
echo "Tag ${GITHUB_REF_NAME} verified as ancestor of main."
35+
36+
# Pinned explicitly to avoid pulling a compromised "latest" at release time; bump via dedicated PR.
37+
- run: npm i -g corepack@0.35.0 && corepack enable
38+
# setup-node does not enable any package-manager cache here (no `cache:` input),
39+
# so cache poisoning is not a concern on this release workflow.
40+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # zizmor: ignore[cache-poisoning] v6.4.0
41+
with:
42+
registry-url: 'https://registry.npmjs.org'
43+
node-version-file: '.nvmrc'
44+
45+
# npm 11.5.1 or later is required for OIDC. Pinned explicitly to avoid
46+
# pulling a compromised "latest" at release time; bump via dedicated PR.
47+
- run: npm install -g npm@11.16.0
48+
49+
- name: Install root JS dependencies
50+
run: pnpm install --frozen-lockfile
51+
52+
- name: Build JS assets
53+
run: pnpm run build
54+
55+
- name: Publish on NPM
56+
run: pnpm publish --recursive --access public --no-git-checks --provenance

0 commit comments

Comments
 (0)