Skip to content

Commit 261e539

Browse files
committed
Fix release notes and maintain versioned README downloads
1 parent 59b22ff commit 261e539

11 files changed

Lines changed: 446 additions & 26 deletions

‎.github/workflows/release.yml‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
env:
3737
RELEASE_TAG: ${{ github.ref_name }}
3838
run: node scripts/release-version.mjs "$RELEASE_TAG"
39+
- name: Prepare notes for this version
40+
env:
41+
RELEASE_TAG: ${{ github.ref_name }}
42+
run: node scripts/release-notes.mjs "$RELEASE_TAG" "$RUNNER_TEMP/release/release-notes.md"
3943
- name: Lint, typecheck, test, and build
4044
run: npm run check
4145
- name: Pack and verify installation
@@ -48,6 +52,7 @@ jobs:
4852
path: |
4953
${{ runner.temp }}/release/*.tgz
5054
${{ runner.temp }}/release/*.sha256
55+
${{ runner.temp }}/release/release-notes.md
5156
if-no-files-found: error
5257
retention-days: 7
5358

@@ -73,8 +78,16 @@ jobs:
7378
PACKAGE_FILE: ${{ needs.package.outputs.filename }}
7479
run: |
7580
sha256sum --check "$PACKAGE_FILE.sha256"
76-
args=(--repo "$GITHUB_REPOSITORY" --verify-tag --title "$RELEASE_TAG" --generate-notes)
81+
args=(--repo "$GITHUB_REPOSITORY" --verify-tag --title "$RELEASE_TAG" --notes-file release-notes.md)
7782
if [[ "$PRERELEASE" == "true" ]]; then
7883
args+=(--prerelease --latest=false)
7984
fi
8085
gh release create "$RELEASE_TAG" "$PACKAGE_FILE" "$PACKAGE_FILE.sha256" "${args[@]}"
86+
87+
update-readme:
88+
name: Update the stable package download
89+
needs: [package, publish]
90+
if: needs.package.outputs.prerelease == 'false'
91+
permissions:
92+
contents: write
93+
uses: ./.github/workflows/update-release-readme.yml
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update release download in README
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: write
9+
10+
concurrency:
11+
group: release-readme
12+
cancel-in-progress: false
13+
14+
jobs:
15+
update:
16+
name: Link the latest published stable package
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
steps:
20+
- name: Check out updater
21+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22+
with:
23+
persist-credentials: false
24+
- name: Set up Node.js
25+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
26+
with:
27+
node-version: 22
28+
cache: npm
29+
- name: Install script dependencies
30+
run: npm ci --ignore-scripts
31+
- name: Update README on the default branch
32+
env:
33+
GH_TOKEN: ${{ github.token }}
34+
run: node scripts/update-release-readme.mjs "$GITHUB_REPOSITORY"

‎AGENTS.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ For common investigations:
3838
- **Why is polling inactive or duplicated?** Read architecture ownership,
3939
workflow section 1, and installation registration details.
4040

41+
For release changes, read the README's **GitHub Actions and releases** section,
42+
`CHANGELOG.md`, and `.github/workflows/release.yml`. Every release tag must have
43+
an exact version section in the changelog. `scripts/release-notes.mjs` extracts
44+
that section; `scripts/update-release-readme.mjs` maintains the marked installation
45+
block on the default branch after stable publication. Keep its markers intact.
46+
4147
## From documentation to source
4248

4349
- `src/index.ts` loads the combined plugin; `src/plugins/` contains the scheduler

‎CHANGELOG.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
3+
Release descriptions come from the exact version section committed with the tag.
4+
Keep unreleased changes here, then move them into a `## MAJOR.MINOR.PATCH` section
5+
before creating the release tag. Prerelease headings include the full version,
6+
for example `## 0.7.0-beta.1`.
7+
8+
## Unreleased
9+
10+
### Fixed
11+
12+
- Generate release descriptions from the matching changelog section, so publishing
13+
a tag before its PR merges no longer produces notes about an earlier release.
14+
- Show the latest published stable package's versioned download URL in the README
15+
and update it automatically after successful stable releases.
16+
17+
## 0.6.2
18+
19+
### Fixed
20+
21+
- Keep the automation owner service active with a heartbeat during long-running
22+
worker sessions, preserving dispatcher access for task completion and PR publication.
23+
- Verify the owner process before sending heartbeat requests and prevent overlapping
24+
requests with a bounded timeout.
25+
- Attempt every cleanup step during shutdown, releasing scheduler and dispatcher
26+
locks even when another cleanup fails, so the plugin can start again.
27+
28+
### Validation and documentation
29+
30+
- Add regression coverage for owner heartbeats and shutdown cleanup failures.
31+
- Document owner lifetime, lock cleanup, and recovery behavior.
32+
33+
## 0.6.1
34+
35+
### Documentation
36+
37+
- Add detailed bot workflow diagrams and a documentation map in `AGENTS.md`.
38+
- Expand bundled bot instructions for planning, delegation, verification, and
39+
handing publication back to the dispatcher.
40+
- Add the README banner showing an OpenCode2 agent executing a task.

‎README.md‎

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,28 @@ Nothing needs to be published to npm. `$HOME` expands to your home directory.
2323

2424
## Install from a .tgz package
2525

26-
1. Download/copy the archive to the machine running OpenCode 2 and install it
27-
(replace `VERSION` with the downloaded version):
26+
Run this command on the machine running OpenCode 2:
2827

29-
```bash
30-
npm install --global --prefix "$HOME/.local" "$HOME/Downloads/opencode2-automation-VERSION.tgz"
31-
```
28+
<!-- latest-release:start -->
29+
Latest stable release: **[v0.6.2](https://github.com/d3cker/opencode2-github-automation/releases/tag/v0.6.2)**.
3230

33-
`postinstall` registers both the plugin and TUI automatically. No `sudo`,
34-
source checkout, or manual config editing is needed. Do not add
35-
`--ignore-scripts`; npm needs network access to install dependencies.
31+
[Download the .tgz package](https://github.com/d3cker/opencode2-github-automation/releases/download/v0.6.2/opencode2-automation-0.6.2.tgz) · [SHA-256 checksum](https://github.com/d3cker/opencode2-github-automation/releases/download/v0.6.2/opencode2-automation-0.6.2.tgz.sha256)
32+
33+
```bash
34+
npm install --global --prefix "$HOME/.local" "https://github.com/d3cker/opencode2-github-automation/releases/download/v0.6.2/opencode2-automation-0.6.2.tgz"
35+
```
36+
<!-- latest-release:end -->
3637

37-
2. Restart the service when its sessions are idle:
38+
`postinstall` registers both the plugin and TUI automatically. No `sudo`,
39+
source checkout, or manual config editing is needed. Do not add
40+
`--ignore-scripts`; npm needs network access to install dependencies.
41+
You can also download the archive and pass its local path to the same command.
3842

39-
```bash
40-
opencode2 service restart
41-
```
43+
Restart the service when its sessions are idle:
44+
45+
```bash
46+
opencode2 service restart
47+
```
4248

4349
The CLI is now at `$HOME/.local/bin/opencode2-automation`. If `$HOME/.local/bin`
4450
is on your PATH, you can use the shorter `opencode2-automation` command.
@@ -122,15 +128,13 @@ A reboot-only task does not handle later `opencode2 service restart` calls.
122128

123129
## Update from a .tgz package
124130

125-
Wait for active bot work to finish. Download the new archive, then:
126-
127-
1. Install the new file using the **same prefix** as before:
131+
Wait for active bot work to finish, then:
128132

129-
```bash
130-
npm install --global --prefix "$HOME/.local" /absolute/path/to/opencode2-automation-NEW_VERSION.tgz
131-
```
133+
1. Run the versioned command in [Install from a .tgz package](#install-from-a-tgz-package)
134+
using the **same prefix** as before. The README on the default branch links to
135+
the latest published stable package.
132136

133-
Replace the example path with your archive. `postinstall` refreshes registration;
137+
`postinstall` refreshes registration;
134138
project settings and queues are preserved. Do not run `init` again.
135139

136140
2. Reload the service:
@@ -292,17 +296,35 @@ copy it to another machine and follow the `.tgz` instructions above.
292296
- **Releases:** push a SemVer tag to build and publish a GitHub Release with the
293297
`.tgz` and SHA-256 checksum. CI verifies that the tag matches the committed
294298
version in `package.json` and `package-lock.json`. Tests and package installation must pass.
299+
Release notes come from the exact version section in [CHANGELOG.md](CHANGELOG.md)
300+
at that tag, independently of PR merge timing. Missing, duplicate, or empty
301+
version sections stop the release before publication.
295302

296-
For a stable release, merge the PR first, then update your local `main` branch.
297-
With a clean working tree, run (replace `0.6.0` with your next unused version):
303+
For a stable release, prepare a changelog section such as `## 0.6.3` with the
304+
changes for that version, merge the PR, then update your local `main` branch.
305+
With a clean working tree, run (replace `0.6.3` with your next unused version,
306+
matching the changelog heading):
298307

299308
```bash
300-
npm version 0.6.0
301-
git push --atomic origin HEAD v0.6.0
309+
npm version 0.6.3
310+
git push --atomic origin HEAD v0.6.3
302311
```
303312

304313
`npm version` updates both manifests, creates a commit, and tags it automatically.
305314
The push sends the current branch and tag together. For testing, use a version
306315
such as `0.7.0-beta.1` on a feature branch; CI marks it as a prerelease.
307316
CI does not rewrite versions or publish to npm. Releases use the built-in
308317
`GITHUB_TOKEN`; no npm token or extra secret is needed.
318+
319+
After successful stable publication, the **Update release download in README**
320+
workflow reads GitHub's latest stable release and checks that its archive and
321+
checksum are uploaded. It commits the versioned installation block to the current
322+
default branch. Prereleases do not trigger this update. A tag's README and the
323+
README inside an existing archive remain snapshots from their build.
324+
325+
The updater needs `contents: write` and branch rules that permit its README commit.
326+
It preserves content outside the marked block and retries conflicting edits using
327+
the current file. If this step fails, the release remains published; resolve the
328+
reported permission or content problem, then run **Update release download in README**
329+
manually from Actions. The rerun selects the latest stable release again and does
330+
nothing if the README is already current. Do not rerun publication to repair a link.

‎docs/installation.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Start with the [README](../README.md) for `.tgz` or source installation, updates
44
project configuration, headless startup, and removal. This page covers details
55
and troubleshooting.
66

7+
The README's package installation command contains the versioned GitHub asset URL
8+
for the latest published stable release. Its default-branch copy is updated after
9+
successful stable publication; prereleases do not replace that link. For upgrades,
10+
use the current default-branch README rather than a copy from an older archive or
11+
tag, and keep the same installation prefix. Maintainer setup and retry instructions
12+
are in [GitHub Actions and releases](../README.md#github-actions-and-releases).
13+
714
## Package registration
815

916
`npm install --global` runs the bundled `postinstall` script. It writes two small

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"files": [
77
"dist",
88
"README.md",
9+
"CHANGELOG.md",
910
"img",
1011
"docs",
1112
"prompts",
@@ -31,7 +32,7 @@
3132
"build": "tsc -p tsconfig.json",
3233
"typecheck": "tsc -p tsconfig.test.json",
3334
"lint": "eslint src test scripts eslint.config.mjs --max-warnings 0",
34-
"test": "node --import tsx --test test/*.test.ts",
35+
"test": "node --import tsx --test test/*.test.ts test/*.test.mjs",
3536
"check": "npm run lint && npm run typecheck && npm test && npm run build",
3637
"package:check": "node scripts/package-check.mjs",
3738
"install-local": "bash scripts/install-local.sh"

‎scripts/package-check.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ try {
1818
const [archive] = JSON.parse(packed.stdout);
1919
assert.equal(archive.version, pkg.version, "Packed version must match package.json");
2020
assert.equal(archive.filename, basename(archive.filename), "Archive name must not contain a directory");
21-
for (const required of ["dist/index.js", "dist/tui.js", "dist/setup.js", "dist/install.js", "scripts/postinstall.mjs", "prompts/bot.md"]) {
21+
for (const required of ["dist/index.js", "dist/tui.js", "dist/setup.js", "dist/install.js", "scripts/postinstall.mjs", "prompts/bot.md", "CHANGELOG.md"]) {
2222
assert.ok(archive.files.some(file => file.path === required), `Missing packaged file: ${required}`);
2323
}
2424
const file = join(output, archive.filename), prefix = join(temporary, "prefix"), config = join(temporary, "config");

‎scripts/release-notes.mjs‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { mkdir, readFile, writeFile } from "node:fs/promises";
2+
import { dirname } from "node:path";
3+
import { pathToFileURL } from "node:url";
4+
import semver from "semver";
5+
6+
export function releaseVersion(tag) {
7+
const version = tag.startsWith("v") ? tag.slice(1) : tag;
8+
if (!/^[0-9]/.test(version) || version.trim() !== version || !semver.valid(version)) {
9+
throw new Error("Expected a SemVer release tag.");
10+
}
11+
return version;
12+
}
13+
14+
export function releaseNotes(changelog, tag) {
15+
const version = releaseVersion(tag);
16+
const sections = [...changelog.matchAll(/^## (.+)\r?$/gm)];
17+
const matches = sections.filter(section => section[1].trim() === version);
18+
if (matches.length !== 1) {
19+
throw new Error(`CHANGELOG.md must contain exactly one "## ${version}" section.`);
20+
}
21+
const section = matches[0];
22+
const next = sections[sections.indexOf(section) + 1];
23+
const notes = changelog.slice(section.index + section[0].length, next?.index).trim();
24+
if (!notes || !/^[-*] \S/m.test(notes)) {
25+
throw new Error(`CHANGELOG.md section ${version} must contain release notes as bullet points.`);
26+
}
27+
return `${notes}\n`;
28+
}
29+
30+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
31+
try {
32+
if (process.argv.length !== 4) throw new Error("Usage: node scripts/release-notes.mjs TAG OUTPUT_FILE");
33+
const notes = releaseNotes(await readFile("CHANGELOG.md", "utf8"), process.argv[2]);
34+
await mkdir(dirname(process.argv[3]), { recursive: true });
35+
await writeFile(process.argv[3], notes);
36+
console.log(`Prepared release notes for ${process.argv[2]}.`);
37+
} catch (error) {
38+
console.error(error.message);
39+
process.exitCode = 1;
40+
}
41+
}

0 commit comments

Comments
 (0)