diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index a0dbbd8..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Publish -on: - release: - types: [ published ] - -permissions: - contents: read - id-token: write - -jobs: - publish: - name: Publish to npm - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '24.x' - registry-url: 'https://registry.npmjs.org' - # trusted publishing needs npm 11.5.1 or newer, whatever the runner's Node bundles - - run: npm install --global npm@^11.5.1 - - run: npm ci - - - name: Check the tag matches the version - run: | - version="v$(node -p "require('./package.json').version")" - if [ "$version" != "$GITHUB_REF_NAME" ]; then - echo "The release is tagged $GITHUB_REF_NAME, but package.json is at $version" >&2 - exit 1 - fi - - - name: Check the changelog has this version - run: | - version="$(node -p "require('./package.json').version")" - if ! grep -Eq "^## ${version//./\\.} - " CHANGELOG.md; then - echo "CHANGELOG.md has no section for $version" >&2 - exit 1 - fi - - - name: Lint - run: npm run lint - - name: Test - run: npm test - - - name: Publish - run: npm publish diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d81f47e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Release +on: + push: + branches: [ main ] + +permissions: {} + +# a release pull request is amended in place as commits land, so two runs must not race for it +concurrency: + group: release + cancel-in-progress: false + +jobs: + release-please: + name: Release pull request + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + # keeps a pull request open that bumps the version and writes CHANGELOG.md from the commit + # subjects since the last tag. Merging it tags v and publishes the GitHub release, + # which is what the publish job below waits for + - id: release + uses: googleapis/release-please-action@v5 + + publish: + name: Publish to npm + needs: release-please + # a release created with GITHUB_TOKEN does not fire `release: published`, so nothing would + # start a workflow of its own: the publish hangs off release-please's own output instead + if: needs.release-please.outputs.release_created == 'true' + runs-on: ubuntu-latest + environment: release + permissions: + contents: read + id-token: write # npm trusted publishing + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.release-please.outputs.tag_name }} + - uses: actions/setup-node@v4 + with: + node-version: '24.x' + registry-url: 'https://registry.npmjs.org' + # trusted publishing needs npm 11.5.1 or newer, whatever the runner's Node bundles + - run: npm install --global npm@^11.5.1 + - run: npm ci + + # a pull request opened by GITHUB_TOKEN does not start workflows, so the release pull + # request itself gets no CI run: lint and the suite run here, before anything is published + - name: Lint + run: npm run lint + - name: Test + run: npm test + + - name: Publish + run: npm publish diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..a915e8c --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.1" +} diff --git a/AGENTS.md b/AGENTS.md index 9a93014..5b184b3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -167,15 +167,57 @@ working, unchecked by tsc and ESLint, and it broke twice while it existed. ## Releasing Published to npm as `@titanium-sdk/language-server`; the command it installs is still -`titanium-language-server`. A release is a pull request that bumps `version` and renames -`CHANGELOG.md`'s `## Unreleased` heading to `## - `, with a new, empty -`## Unreleased` above it. Then a GitHub Release tagged `v` from the merge, with that -section as its notes: `publish.yml` checks the tag matches and the changelog has the version's -heading, runs lint and tests, and publishes through npm's trusted publishing, with provenance and -no stored token. - -The changelog is kept up as changes land, so a release never has to dig through history for it — -see below. +`titanium-language-server`. **Releases are release-please's job, not a hand-written pull request.** +`release.yml` runs `googleapis/release-please-action` on every push to `main`, and it keeps a +release pull request open that bumps `version` in `package.json` and `package-lock.json` and writes +the new `CHANGELOG.md` section from the commits since the last tag. Releasing is merging that pull +request. release-please then tags `v` and publishes the GitHub release, and the publish job +in the same workflow runs lint and the suite and publishes through npm's trusted publishing, with +provenance and no stored token. + +Two things follow from that. + +- **The release is only as good as the commit subjects.** release-please reads them, not the diff, + so a subject is what a user will read in the changelog and in the release notes. Pull requests are + squash-merged, so the subject that lands is the pull request's title. +- **`.release-please-manifest.json` is the source of truth for the current version**, and + release-please owns it along with `version` in `package.json`. Do not bump either by hand; the + only reason to touch the manifest is to recover from a release that went wrong. + +`release-please-config.json` sets `bump-minor-pre-major`, so while the package is below 1.0 a +breaking change bumps the minor rather than jumping to 1.0.0. Going to 1.0.0 is a deliberate act: +drop that setting, or land a commit with `Release-As: 1.0.0` in its body. + +The publish job runs in the `release` environment, and npm's trusted publisher for the package has +to name this repository, the workflow `release.yml` and that environment. The workflow's filename is +part of what npm checks, so renaming it means changing that setting too. + +### Steering what comes out + +The commit is the input, but release-please takes four kinds of instruction in it. + +- `feat:` is a minor bump, `fix:` and `perf:` are patches, and `feat!:` — or a `BREAKING CHANGE:` + footer — is breaking. `docs`, `test`, `ci`, `build`, `chore`, `refactor` and `style` are released + as nothing and stay out of the changelog, which is the same line the old hand-written changelog + drew. +- **Several entries from one commit.** Put more conventional-commit lines at the *bottom* of the + commit body and each becomes its own changelog entry — the way to give a squashed pull request + that did two user-visible things two lines. +- **Fixing an entry after the merge.** release-please re-reads the merged pull request's body, so + editing it to add a block fixes what the changelog will say, without rewriting history: + + ``` + BEGIN_COMMIT_OVERRIDE + feat(tss): offer colour names where a colour is expected + + fix(view): stop warning about an attribute a custom tag does have + END_COMMIT_OVERRIDE + ``` + + This only works because the merge was a squash — with a plain merge release-please cannot tell + which commit the override belongs to. +- **Choosing the version.** `Release-As: 0.4.0` in a commit body makes the next release pull request + that version, whatever the commits since the last tag would have picked. ## Testing @@ -356,16 +398,19 @@ one case. ## Commits and pull requests Conventional Commits, for example `feat(tss): …`, `fix(view): …`, `test: …`. Issue references go in -the commit body rather than the subject. +the commit body rather than the subject. **The subject is read by release-please**: a `feat`, `fix` +or `perf` subject is published as a changelog line and as release notes, so write it for someone +using the server rather than someone reading the diff. Pull requests are squash-merged, so it is the +pull request's title that lands — and a `feat!:` subject, or a `BREAKING CHANGE:` footer, moves the +version. See [Releasing](#releasing) for the rest of what a commit can tell release-please. Every pull request body **closes its issues with GitHub's keyword syntax** — `Closes #9`, one per issue — so merging shuts them automatically. `Refs #9` only links, and leaves someone to close it by hand later; use it only for an issue the pull request genuinely does not finish. -A pull request that changes something a user would notice — a `feat`, a `fix`, a `perf`, a change -to what the package needs to run — **adds a line under `## Unreleased` in `CHANGELOG.md`**, under -the subheading for the area it touches, ending with its own number: `(#70)`. Write it for someone -using the server, not someone reading the code. Tests, CI, refactors and docs need no line. +**Do not edit `CHANGELOG.md`.** release-please writes it from the commits in the release pull +request; a line added by hand is a conflict waiting for that pull request. A change a user would +notice earns its changelog line by having a `feat`, `fix` or `perf` subject worth reading. Work on a branch and open a pull request. Nothing is pushed to `main` directly. Where several changes are in flight, stack the branches. diff --git a/CHANGELOG.md b/CHANGELOG.md index b8082f1..8247a7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,11 @@ # Changelog -What changed in each release of `@titanium-sdk/language-server`, newest first. The numbers are the -pull requests that made each change. +What changed in each release of `@titanium-sdk/language-server`, newest first. -A pull request that changes something a user would notice adds a line under Unreleased. A release -renames that heading to its version and date, and starts a new, empty one above it. - -## Unreleased +From 0.2.0 on, release-please writes this file from the `feat`, `fix` and `perf` commits that have +landed on `main` since the last tag, so nothing here is written by hand. The 0.1.x sections below +came before that and were written by hand; their numbers are the pull requests that made each +change. ## 0.1.1 - 2026-10-31 diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..59a5329 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "node", + "include-component-in-tag": false, + "changelog-path": "CHANGELOG.md", + "bump-minor-pre-major": true + } + } +}