Skip to content

Commit 5bd29fe

Browse files
committed
Prepare first npm prerelease
Separate repository readiness from the irreversible tag that publishes the first public alpha. Pin registry and provenance metadata, verify the exact tagged main state without credentials, and require environment approval before the one-time bootstrap token can publish under next.
1 parent 121272c commit 5bd29fe

7 files changed

Lines changed: 346 additions & 11 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions: {}
8+
9+
concurrency:
10+
group: npm-publish
11+
cancel-in-progress: false
12+
13+
jobs:
14+
verify:
15+
name: Verify release
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 10
18+
permissions:
19+
contents: read
20+
steps:
21+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22+
with:
23+
fetch-depth: 0
24+
persist-credentials: false
25+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
26+
with:
27+
node-version: 24.18.0
28+
package-manager-cache: false
29+
- name: Verify tag and source commit
30+
run: |
31+
# release-source-checks:begin
32+
set -euo pipefail
33+
test "$GITHUB_REPOSITORY" = "firstdraft/cli"
34+
test "$GITHUB_EVENT_NAME" = "push"
35+
test "$GITHUB_REF_TYPE" = "tag"
36+
test "$GITHUB_REF" = "refs/tags/$GITHUB_REF_NAME"
37+
test "$GITHUB_REF_PROTECTED" = "true"
38+
release_sha="$(git rev-parse 'HEAD^{commit}')"
39+
event_sha="$(git rev-parse "${GITHUB_SHA}^{commit}")"
40+
test "$release_sha" = "$event_sha"
41+
git fetch --force --no-tags origin \
42+
"+refs/heads/main:refs/remotes/origin/main" \
43+
"+refs/tags/${GITHUB_REF_NAME}:refs/release-check/tag"
44+
remote_tag_sha="$(git rev-parse 'refs/release-check/tag^{commit}')"
45+
test "$release_sha" = "$remote_tag_sha"
46+
package_version="$(node --print 'JSON.parse(require("node:fs").readFileSync("package.json", "utf8")).version')"
47+
test "$GITHUB_REF_NAME" = "v$package_version"
48+
git rev-list --first-parent refs/remotes/origin/main > "$RUNNER_TEMP/main-first-parent"
49+
grep -Fqx "$release_sha" "$RUNNER_TEMP/main-first-parent"
50+
# release-source-checks:end
51+
- run: npm ci --ignore-scripts
52+
- run: npm audit
53+
- run: npm run check
54+
- run: npm pack --dry-run --json --ignore-scripts
55+
56+
publish:
57+
name: Publish to npm
58+
needs: verify
59+
runs-on: ubuntu-latest
60+
timeout-minutes: 10
61+
environment: npm
62+
permissions:
63+
contents: read
64+
id-token: write
65+
steps:
66+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
67+
with:
68+
fetch-depth: 0
69+
persist-credentials: false
70+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
71+
with:
72+
node-version: 24.18.0
73+
package-manager-cache: false
74+
registry-url: https://registry.npmjs.org/
75+
- name: Verify approved release
76+
env:
77+
NPM_RELEASE_ENABLED: ${{ vars.NPM_RELEASE_ENABLED }}
78+
# Inline by design: no tagged repository script runs while the bootstrap secret is in scope.
79+
# test/package.test.js enforces synchronization with verify.
80+
run: |
81+
# release-source-checks:begin
82+
set -euo pipefail
83+
test "$NPM_RELEASE_ENABLED" = "true"
84+
test "$GITHUB_REPOSITORY" = "firstdraft/cli"
85+
test "$GITHUB_EVENT_NAME" = "push"
86+
test "$GITHUB_REF_TYPE" = "tag"
87+
test "$GITHUB_REF" = "refs/tags/$GITHUB_REF_NAME"
88+
test "$GITHUB_REF_PROTECTED" = "true"
89+
release_sha="$(git rev-parse 'HEAD^{commit}')"
90+
event_sha="$(git rev-parse "${GITHUB_SHA}^{commit}")"
91+
test "$release_sha" = "$event_sha"
92+
git fetch --force --no-tags origin \
93+
"+refs/heads/main:refs/remotes/origin/main" \
94+
"+refs/tags/${GITHUB_REF_NAME}:refs/release-check/tag"
95+
remote_tag_sha="$(git rev-parse 'refs/release-check/tag^{commit}')"
96+
test "$release_sha" = "$remote_tag_sha"
97+
package_version="$(node --print 'JSON.parse(require("node:fs").readFileSync("package.json", "utf8")).version')"
98+
test "$GITHUB_REF_NAME" = "v$package_version"
99+
git rev-list --first-parent refs/remotes/origin/main > "$RUNNER_TEMP/main-first-parent"
100+
grep -Fqx "$release_sha" "$RUNNER_TEMP/main-first-parent"
101+
# release-source-checks:end
102+
- name: Publish verified source
103+
run: npm publish --access public --tag next --provenance --ignore-scripts
104+
# Remove this credential after the first publish enables trusted publishing.
105+
env:
106+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

‎README.md‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,29 @@
33
`firstdraft` is the command-line client for [First Draft](https://github.com/firstdraft/firstdraft). It is being
44
built for agents that author and review Foundation Plans with their users.
55

6-
The package is not released yet. This repository contains the auditable command shell, local Foundation Plan
7-
initialization, subject identity generation, conditional whole-document push, and whole-graph analysis status
8-
polling, plus explicit compilation and verified local artifact materialization; release behavior will arrive in
9-
reviewed increments.
6+
Public alpha releases use npm's `next` tag. This release line contains the auditable command shell, local Foundation
7+
Plan initialization, subject identity generation, conditional whole-document push, whole-graph analysis status
8+
polling, explicit compilation, and verified local artifact materialization. Interfaces may change between
9+
prereleases, and publishing the CLI does not make the wider First Draft service generally available.
1010

1111
## Requirements
1212

1313
- Running the CLI: Node.js 22.0.0 or newer
1414
- Working on this repository: Node.js 24.18.0 (pinned in `.tool-versions`)
1515

16+
## Installation
17+
18+
Once npm reports a public alpha, install the current prerelease explicitly:
19+
20+
```sh
21+
npm install --global firstdraft@next
22+
firstdraft --version
23+
```
24+
25+
There is intentionally no stable `latest` release yet. Pin an exact prerelease version instead of `next` when a
26+
repeatable installation matters. Remote Plan push, status, and compilation commands require a compatible First
27+
Draft service and are currently intended for coordinated trials.
28+
1629
## Development
1730

1831
```sh
@@ -161,7 +174,7 @@ unexpected programming defects.
161174
explicitly invoked API command.
162175
- Package contents are allowlisted and checked before release.
163176
- CI exercises the exact minimum Node.js version separately from current development tooling.
164-
- Public releases will use npm provenance after the first useful version bootstraps trusted publishing.
177+
- Public packages carry npm provenance linking their registry bytes to the reviewed GitHub workflow and commit.
165178

166179
Security issues should follow the
167180
[private reporting instructions](https://github.com/firstdraft/cli/security/advisories/new).

‎RELEASING.md‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Releasing First Draft CLI
2+
3+
Publishing is a separate, explicit action after a release-preparation pull request has merged. npm registry bytes
4+
and package versions cannot be replaced, so do not create or push a release tag as a dry run.
5+
6+
## Repository and registry setup
7+
8+
Before the first release, a repository administrator must:
9+
10+
1. Confirm `firstdraft/cli` is public. The release workflow deliberately removes checkout credentials and re-fetches
11+
the public release refs anonymously.
12+
2. Protect `main` with pull-request and CI requirements, and add a `v*` tag ruleset that restricts tag creation,
13+
update, and deletion.
14+
3. Create a GitHub environment named `npm`, restrict it to release tags, require a reviewer, prevent self-review,
15+
and add the environment variable `NPM_RELEASE_ENABLED=true`. The workflow fails before publishing when this
16+
variable is absent.
17+
4. Confirm that the bootstrap publisher account has write-protecting 2FA enabled. The first publish creates this
18+
unscoped package under that account; organization access cannot be granted before the package exists.
19+
5. Create a one-day granular npm token with read/write access to All Packages, no organization-management access,
20+
and bypass 2FA enabled. A new unscoped package cannot yet be selected individually. Add it directly as the `npm`
21+
environment secret `NPM_TOKEN`; never put it in an Issue, chat, workflow file, repository file, or command
22+
history.
23+
24+
The token is a one-time bootstrap credential. After the package exists, use the repository-pinned Node.js 24.18.0
25+
toolchain with npm 11.16.0 to give the npm organization durable read/write access and configure trusted publishing:
26+
27+
```sh
28+
npm --version
29+
npm access grant read-write firstdraft.com:developers firstdraft
30+
```
31+
32+
```sh
33+
npm trust github firstdraft \
34+
--repository firstdraft/cli \
35+
--file publish.yml \
36+
--environment npm \
37+
--allow-publish
38+
npm trust list firstdraft
39+
```
40+
41+
Confirm the listed relationship identifies `firstdraft/cli`, `publish.yml`, the `npm` environment, and publish
42+
permission. Before creating another release tag, merge a follow-up pull request that removes the `NODE_AUTH_TOKEN`
43+
environment from the publish step. Then remove the GitHub secret, revoke the bootstrap token, and configure the
44+
package to disallow token publication. The workflow continues through GitHub OIDC without a persistent npm
45+
credential.
46+
47+
## Prepare a release
48+
49+
1. Update `package.json` and `package-lock.json` to the exact release version.
50+
2. Keep prereleases on the `next` dist-tag. Do not create `latest` until a stable release is intentionally approved.
51+
3. Update user-facing documentation and release notes for behavior changes.
52+
4. Run:
53+
54+
```sh
55+
npm ci --ignore-scripts
56+
npm audit
57+
npm run check
58+
```
59+
60+
5. Merge the reviewed pull request only after local and hosted checks pass.
61+
62+
## Publish
63+
64+
The manual boundary is creation of the version tag. From an up-to-date, clean `main`, verify the intended commit and
65+
then create and push `v<package-version>`. For version `0.1.0-alpha.1`, the tag is `v0.1.0-alpha.1`.
66+
Push one release tag at a time; the workflow serializes publication, but GitHub retains at most one pending run in a
67+
concurrency group.
68+
69+
The workflow rejects accidental or stale inputs unless they use a protected `v*` tag in `firstdraft/cli`, the tag
70+
equals `v` plus the version in `package.json`, the remote tag still identifies the triggering commit, and that commit
71+
appears in the first-parent history of `origin/main`. First-parent membership allows an older reviewed `main` state
72+
after another change lands while rejecting intermediate commits from a merged side branch. The workflow reruns the
73+
complete check, waits for approval in the `npm` environment, reverifies the remote refs, and publishes to the public
74+
registry with provenance under `next`.
75+
76+
The tag ruleset and `npm` environment approval are the external trust boundary because a tag-push run loads its
77+
workflow from the tagged commit. Before approving the `npm` deployment, the reviewer must confirm:
78+
79+
- The tag, package version, and commit SHA are the intended release.
80+
- The commit is a known reviewed state in protected `main` history and its required checks passed.
81+
- `.github/workflows/publish.yml` at that commit is the reviewed workflow, still selects the `npm` environment, and
82+
publishes only under `next` with provenance.
83+
- The unprivileged verification job passed for that exact commit.
84+
85+
Do not move or reuse a release tag. If the tagged commit is not a first-parent state of `main`, merge the intended
86+
change and prepare a new version rather than moving an already shared tag.
87+
88+
## Verify and recover
89+
90+
After publication, inspect the registry before retrying any reported failure; the package may already exist. Verify
91+
the exact version, `next` dist-tag, integrity metadata, and provenance metadata:
92+
93+
```sh
94+
npm view firstdraft@0.1.0-alpha.1 \
95+
version dist.integrity dist.shasum repository.url engines bin --json
96+
npm dist-tag ls firstdraft
97+
```
98+
99+
Install `firstdraft@0.1.0-alpha.1` into a fresh temporary prefix, confirm `firstdraft --version`, compare the packed
100+
file list with the release workflow, and run `npm audit signatures` after an exact installation.
101+
102+
A published version cannot be overwritten or reused. For a bad release, move `next` to a known-good version,
103+
deprecate the bad version, and publish a corrected higher version. Treat unpublishing as an exceptional incident
104+
response, not a routine rollback.

‎SECURITY.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ Please report suspected vulnerabilities through a
44
[private GitHub security advisory](https://github.com/firstdraft/cli/security/advisories/new). Do not include
55
sensitive details in a public Issue.
66

7-
The CLI has not released a supported version yet. This policy will name supported release lines before the first
8-
public package is published.
7+
## Supported versions
8+
9+
Before the first public npm publication, there is no supported release. During alpha, only the prerelease currently
10+
identified by npm's `next` tag receives security fixes. Earlier prereleases and unreleased source snapshots are not
11+
supported release lines. The alpha interface may change without backward compatibility between versions.

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firstdraft",
3-
"version": "0.0.0",
3+
"version": "0.1.0-alpha.1",
44
"description": "Command-line interface for First Draft",
55
"license": "MIT",
66
"type": "module",
@@ -23,7 +23,10 @@
2323
},
2424
"homepage": "https://github.com/firstdraft/cli#readme",
2525
"publishConfig": {
26-
"access": "public"
26+
"access": "public",
27+
"provenance": true,
28+
"registry": "https://registry.npmjs.org/",
29+
"tag": "next"
2730
},
2831
"scripts": {
2932
"check": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run pack:check && npm run pack:smoke",

0 commit comments

Comments
 (0)