Skip to content

Commit 807b9d3

Browse files
authored
chore(release): phase 1 – wire changesets (dry-run), add npm auth config (Fission-AI#114)
* Clarify release automation proposal * chore(release): phase 1 – wire up changesets action (dry-run publish) and GitHub release drafting * ci(release): phase 1 – add NODE_AUTH_TOKEN alias and registry/auth config for npm (dry-run)
1 parent b3d05d2 commit 807b9d3

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

.github/workflows/release-prepare.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ permissions:
88
contents: write
99
pull-requests: write
1010

11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: false
14+
1115
jobs:
1216
prepare:
17+
if: github.repository == 'Fission-AI/OpenSpec'
1318
runs-on: ubuntu-latest
1419
steps:
1520
- uses: actions/checkout@v4
@@ -24,6 +29,9 @@ jobs:
2429
with:
2530
node-version: '20'
2631
cache: 'pnpm'
32+
registry-url: 'https://registry.npmjs.org'
33+
scope: '@fission-ai'
34+
always-auth: true
2735

2836
- run: pnpm install --frozen-lockfile
2937

@@ -32,6 +40,9 @@ jobs:
3240
uses: changesets/action@v1
3341
with:
3442
title: 'chore(release): version packages'
43+
createGithubReleases: true
44+
publish: "echo 'Dry run: changeset publish would execute here'"
3545
env:
3646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
47+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Why
2+
Today’s process requires maintainers to merge the Changesets PR, cut a tag, and draft the GitHub release by hand. npm publish then runs from our existing workflow after the GitHub release is published. The human-in-the-loop steps (versioning, tagging, release notes) slow us down and risk drift between npm, tags, and changelog.
3+
4+
## What Changes
5+
- Use the single `changesets/action` on pushes to `main` to either open/update the version PR or, when the release PR is merged, run our publish command automatically using repository secrets.
6+
- Add a `release` script that builds and runs `changeset publish` so the action handles version bumps, changelog commits, npm publish, and GitHub releases end-to-end.
7+
- Enable `createGithubReleases: true` so GitHub releases are created from the changeset data right after publishing.
8+
- Document the automated flow, required secrets, guardrails, and recovery steps (rollback, hotfixes).
9+
10+
## Two-Phase Rollout (Two PRs)
11+
1) Phase 1 — Dry run (no publish)
12+
- Update the existing `release-prepare.yml` to wire up `changesets/action` with `createGithubReleases: true` and a no-op `publish` command (e.g., `echo 'dry run'`).
13+
- Keep `.github/workflows/release-publish.yml` intact. This avoids any publish path changes while we verify that the version PR behavior and permissions are correct.
14+
- Add a repository guard (`if: github.repository == 'Fission-AI/OpenSpec'`) and a concurrency group for safety.
15+
16+
2) Phase 2 — Enable publish and consolidate
17+
- Add `"release": "pnpm run build && pnpm exec changeset publish"` to `package.json`.
18+
- Change `release-prepare.yml` to use `with: publish: pnpm run release` and `env: NPM_TOKEN: \\${{ secrets.NPM_TOKEN }}` plus the default `GITHUB_TOKEN`.
19+
- Remove `.github/workflows/release-publish.yml` to avoid double-publish. Publishing now happens when the version PR is merged.
20+
21+
## Guardrails
22+
- Concurrency: `concurrency: { group: release-\\${{ github.ref }}, cancel-in-progress: false }` on the workflow to serialize releases.
23+
- Repository/branch guard: run publish logic only on upstream `main` (`if: github.repository == 'Fission-AI/OpenSpec' && github.ref == 'refs/heads/main'`).
24+
- Permissions: ensure `contents: write` and `pull-requests: write` for opening/updating the version PR; `packages: read` optional.
25+
26+
## Rollback and Hotfixes
27+
- Rollback: revert the release PR merge (which reverts version bumps/changelog); if a tag or GitHub release was created, delete the tag and release; deprecate the npm version if necessary (`npm deprecate @fission-ai/openspec@x.y.z 'reason'`).
28+
- Hotfix (urgent, no pending changesets): create a changeset for the fix and merge the release PR; in emergencies, run a manual bump/publish but reconcile with Changesets by adding a follow-up changeset to align versions.
29+
30+
## Required Secrets
31+
- `NPM_TOKEN` with publish rights for the `@fission-ai` scope.
32+
- Default `GITHUB_TOKEN` (provided by GitHub) for opening/updating the version PR and creating GitHub releases.
33+
34+
## How the Maintainer Flow Changes
35+
| Step | Current process | Future process |
36+
| --- | --- | --- |
37+
| Prepare release | Merge changeset PR, then manually draft release notes and tags | Merge release PR; action updates versions and handles changelog automatically |
38+
| Publish npm package | Happens automatically after GitHub release | Happens automatically via `changeset publish` invoked by the action |
39+
| GitHub release | Draft manually and sync with changelog | Action creates GitHub releases from changeset data |
40+
| Docs/process | Follow manual tagging/release steps | Docs describe automated flow + recovery and hotfix paths |
41+
42+
## Impact
43+
- Automation: reuse `.github/workflows/release-prepare.yml` (phase 1: dry-run, phase 2: publish) and remove `.github/workflows/release-publish.yml` in phase 2.
44+
- Package metadata: add `release` script to `package.json`.
45+
- Docs: update README or `/docs` to show the automated flow, secrets, guardrails, and recovery steps.
46+
47+
## Acceptance Criteria
48+
- Phase 1: merges to `main` open/update a version PR; on merge, the action’s `publish` step is a no-op; no npm publish occurs; logs confirm intended behavior; GitHub releases creation is wired but inert due to no publish.
49+
- Phase 2: merges to `main` run `pnpm run release` from the action; npm package publishes successfully; GitHub release is created automatically; `.github/workflows/release-publish.yml` is removed; no duplicate publishes occur.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## 1. Release workflow automation
2+
- [ ] 1.1 Add a `.github/workflows/release.yml` that runs on pushes to `main`, sets up pnpm + Node 20, installs dependencies, and invokes `changesets/action@v1` with `publish: pnpm run release`.
3+
- [ ] 1.2 Configure the action with `createGithubReleases: true` and document required secrets (`NPM_TOKEN`, default `GITHUB_TOKEN`) plus recommended concurrency safeguards.
4+
- [ ] 1.3 Validate the workflow using `act` or a dry-run push to confirm the action opens release PRs when changesets exist and publishes when the release PR merge lands.
5+
6+
## 2. Package release script
7+
- [ ] 2.1 Add a `release` script to `package.json` that builds the project and runs `changeset publish` using pnpm.
8+
- [ ] 2.2 Ensure the script respects the existing `prepare`/`prepublishOnly` hooks to avoid duplicate builds and update documentation or scripts if adjustments are needed.
9+
10+
## 3. Documentation and recovery steps
11+
- [ ] 3.1 Update maintainer docs (e.g., README or `/docs`) with the end-to-end automated release flow, explicitly removing the manual tag/release steps that are no longer required and explaining how changesets drive the release PR.
12+
- [ ] 3.2 Document fallback steps for failed publishes (rerun workflow, manual publish) and the hotfix path when a release must be cut without pending changesets.

0 commit comments

Comments
 (0)