diff --git a/.changeset/README.md b/.changeset/README.md index e8a9155..0c591c3 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -6,4 +6,6 @@ Add a changeset with: vp exec changeset ``` -Merging the resulting release PR on `main` is what triggers the publish workflow. +Merging the resulting release PR on `main` makes the publish workflow stage the +new version on npm. It goes public once a maintainer approves it with +`npm stage approve ` (2FA), using the stage ID from the workflow log. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 784b3f6..2b55fa1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,5 +76,11 @@ jobs: - name: Validate release run: pnpm run release:check - - name: Publish to npm - run: pnpm run release + - name: Stage on npm + run: | + version="$(node -p "require('./package.json').version")" + if [ -n "$(npm view "obsidian-e2e@$version" version 2>/dev/null)" ]; then + echo "obsidian-e2e@$version is already published" + exit 0 + fi + pnpm run release diff --git a/README.md b/README.md index 054a724..96b0fa8 100644 --- a/README.md +++ b/README.md @@ -896,12 +896,15 @@ At a high level: `.obsidian-e2e-artifacts` so maintainers can inspect the same failure snapshots produced locally. - Releases go through Changesets PRs. Merge the version PR that - Changesets opens, then let the release workflow publish to npm. + Changesets opens, and the release workflow stages the version on npm. It + goes public once a maintainer approves it with `npm stage approve + ` (2FA). Maintainer setup notes: - Configure npm trusted publishing for this package and repository so the - GitHub release workflow can publish without a long-lived npm token. + GitHub release workflow can stage releases without a long-lived npm token. + Allow only `npm stage publish` on the trusted publisher, not `npm publish`. - Grant the publish job `id-token: write` so GitHub can mint the OIDC token npm expects, and keep the release workflow permissions aligned with the write actions it needs, such as `contents: write` and `pull-requests: write` for diff --git a/package.json b/package.json index 5b553bb..20eab09 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "url": "git+https://github.com/chhoumann/obsidian-e2e.git" }, "bin": { - "obsidian-e2e": "./dist/runner/bin.mjs" + "obsidian-e2e": "dist/runner/bin.mjs" }, "files": [ "dist" @@ -51,7 +51,7 @@ "check": "vp check", "changeset": "changeset", "dev": "vp pack --watch", - "release": "changeset publish", + "release": "npm stage publish --provenance", "release:check": "vp check && vp test && vp pack", "test": "vp test", "typecheck": "tsc --noEmit",