Skip to content

Commit 02ce94b

Browse files
committed
release: Add automated release workflow
Add a weekly release agent that creates release PRs with notes generated from git history, and a companion publish-release.yml that creates the GitHub release when the PR is merged. Version bumping is handled by scripts/next-version.sh (v0.x.0 minor releases per project policy). The agent is scoped to only modify RELEASE-NOTES.md via allowed-files. Addresses: #71 Assisted-by: AI
1 parent cf02a64 commit 02ce94b

9 files changed

Lines changed: 2022 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
run: |
3131
set -euo pipefail
32-
gh aw compile drafter review fix queue-triage ci-triage --approve
32+
gh aw compile drafter review fix release queue-triage ci-triage --approve
3333
3434
- name: Check for lock drift
3535
run: |

‎.github/workflows/install-labels.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
{ name: 'agent/fix-working', description: 'The fix agent is actively working on this PR', color: 'FBCA04' },
3535
{ name: 'agent/workflow-edits-allowed', description: 'Pre-authorizes agent runs to edit protected files without the request_review gate', color: '5319E7' },
3636
{ name: 'agent/flake-tracker', description: 'Marks the CI flake tracker issue the merge queue analyzer maintains', color: '1D76DB' },
37+
{ name: 'release', description: 'Release PR created by the release agent', color: '0075CA' },
3738
];
3839
3940
const { owner, repo } = context.repo;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish Release
2+
on:
3+
pull_request:
4+
types: [closed]
5+
6+
# When a release PR is merged, create the corresponding GitHub release
7+
# with the release notes from the PR body.
8+
jobs:
9+
publish:
10+
if: |
11+
github.event.pull_request.merged == true &&
12+
contains(github.event.pull_request.labels.*.name, 'release') &&
13+
startsWith(github.event.pull_request.head.ref, 'release/')
14+
runs-on: ubuntu-24.04
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Extract version from branch name
19+
id: version
20+
env:
21+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
22+
run: |
23+
version="${HEAD_REF#release/}"
24+
echo "version=$version" >> "$GITHUB_OUTPUT"
25+
echo "Publishing release: $version"
26+
27+
- name: Create GitHub Release
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
VERSION: ${{ steps.version.outputs.version }}
31+
PR_NUMBER: ${{ github.event.pull_request.number }}
32+
REPO: ${{ github.repository }}
33+
run: |
34+
pr_body=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json body --jq .body)
35+
36+
gh release create "$VERSION" \
37+
--repo "$REPO" \
38+
--title "Release $VERSION" \
39+
--notes "$pr_body"

‎.github/workflows/release.lock.yml‎

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

‎.github/workflows/release.md‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
description: |
3+
Automated release agent for this repository. Runs weekly to create a
4+
release PR with release notes from git history since the last release.
5+
The PR requires human review and approval before merge. When merged,
6+
a separate workflow creates the GitHub release with the tag.
7+
8+
on:
9+
schedule: weekly on monday
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
issues: read
15+
pull-requests: read
16+
17+
model: claude-sonnet-4-5-20250929
18+
engine:
19+
id: claude
20+
tools:
21+
bash: ["*"]
22+
github:
23+
toolsets: [default]
24+
25+
safe-outputs:
26+
github-app:
27+
client-id: ${{ vars.GH_AW_APP_CLIENT_ID }}
28+
private-key: ${{ secrets.GH_AW_APP_PRIVATE_KEY }}
29+
create-pull-request:
30+
max: 1
31+
branch-prefix: release/
32+
allowed-files:
33+
- RELEASE-NOTES.md
34+
noop:
35+
missing-data:
36+
---
37+
38+
# Release Agent
39+
40+
This workflow runs weekly to create a release PR.
41+
42+
## Your task
43+
44+
1. **Check for existing release PRs**: Before doing anything else, run
45+
`gh pr list --label release --state open --json number --jq length`
46+
to check if a release PR is already open. If the count is non-zero,
47+
use `noop` to report that a release PR is already open.
48+
49+
2. **Fetch full history**: The checkout is shallow by default. Run
50+
`git fetch --unshallow --tags` so that all tags and commit history
51+
are available.
52+
53+
3. **Determine the next version**: Run `scripts/next-version.sh` to get
54+
the next version string (e.g., `v0.3.0`).
55+
56+
4. **Generate release notes**: Use GitHub's release notes generation API
57+
as a starting point:
58+
```bash
59+
gh api repos/$GITHUB_REPOSITORY/releases/generate-notes \
60+
-f tag_name="<next-version>" \
61+
-f previous_tag_name="<last-tag>" \
62+
--jq .body
63+
```
64+
Then refine the output: group changes by category (Features, Bug Fixes,
65+
Documentation, Dependencies, Other), add a brief summary at the top,
66+
and highlight any breaking changes.
67+
68+
5. **Write RELEASE-NOTES.md**: Write the final release notes to
69+
`RELEASE-NOTES.md` at the repository root. This file is overwritten
70+
each release.
71+
72+
6. **Create the release PR**: Use the `create-pull-request` safe-output
73+
with:
74+
- **Title**: `Release <version>` (e.g., "Release v0.3.0")
75+
- **Branch**: `<version>` (e.g., "v0.3.0") — the `release/` prefix
76+
is added automatically by the branch-prefix setting
77+
- **Body**: The release notes from RELEASE-NOTES.md
78+
- **Labels**: `release`
79+
80+
7. **Handle edge cases**:
81+
- If there are no changes since the last release, use `noop`
82+
- If you cannot determine the version or history, use `missing-data`
83+
84+
## Constraints
85+
86+
- Never push directly to the default branch
87+
- Only modify RELEASE-NOTES.md — do not touch other files
88+
- Always include "Generated-by: AI" in the PR body
89+
- Require human review for all releases

‎aw.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ includes:
88
- .github/workflows/drafter.md
99
- .github/workflows/review.md
1010
- .github/workflows/fix.md
11+
- .github/workflows/release.md
1112
- .github/workflows/merge.yml
1213
- .github/workflows/install-labels.yml
1314
- .github/workflows/upgrade.yml

‎justfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setup:
2121
2222
# Compile all gh-aw workflow .md sources to .lock.yml (run `just setup` first).
2323
compile:
24-
gh aw compile drafter review fix queue-triage ci-triage --approve
24+
gh aw compile drafter review fix release queue-triage ci-triage --approve
2525

2626
# Setup + compile in one step.
2727
all: setup compile

‎scripts/install-labels.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ const LABELS = [
5858
description: 'Marks the CI flake tracker issue the merge queue analyzer maintains',
5959
color: '1D76DB', // blue
6060
},
61+
{
62+
name: 'release',
63+
description: 'Release PR created by the release agent',
64+
color: '0075CA', // blue
65+
},
6166
];
6267

6368
/**

‎scripts/next-version.sh‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# Determine the next release version by reading git tags.
3+
# This project uses v0.x.0 minor releases.
4+
set -euo pipefail
5+
6+
latest=$(git tag --list 'v*' --sort=-v:refname | head -1)
7+
8+
if [ -z "$latest" ]; then
9+
echo "v0.1.0"
10+
exit 0
11+
fi
12+
13+
# Strip leading 'v', split on '.', bump minor, reset patch
14+
IFS='.' read -r major minor _patch <<< "${latest#v}"
15+
echo "v${major}.$((minor + 1)).0"

0 commit comments

Comments
 (0)