Skip to content

Commit 52016e5

Browse files
authored
Tighten release instructions for agents
Closes #206
1 parent 1cb2837 commit 52016e5

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ The app should be treated as a trusted local control agent. Be conservative with
1414
- Keep pull requests tightly scoped to one issue wherever possible.
1515
- Do not mix implementation work with broad refactors unless the issue explicitly calls for it.
1616
- Prefer existing project patterns once the app scaffold exists.
17+
- Before creating a milestone, verify whether the intended milestone already exists.
18+
- Reuse an existing open milestone instead of creating a duplicate.
19+
- Create a release milestone only when it is missing.
20+
- Do not create future release milestones casually. The active release milestone should normally be the next version after `package.json`.
21+
- Before release work starts, verify the target milestone name exactly matches the version being released, for example `Release 0.1.8` for `package.json` version `0.1.8`.
1722

1823
## Development standards
1924

@@ -82,6 +87,8 @@ Only the maintainer should publish releases.
8287

8388
Release builds are published from tags named `vX.Y.Z`, where `X.Y.Z` must match `package.json`.
8489

90+
Before creating a release milestone, verify whether the intended milestone already exists. Reuse an existing open milestone. Create the milestone only if it is missing. If the milestone exists but is closed, reopen it only when the work truly belongs in that release.
91+
8592
The release workflow is `.github/workflows/release.yml`. It runs on the self-hosted Windows signing runner with the `switchify-signing` label. The runner is expected to have:
8693

8794
- Windows.
@@ -101,6 +108,71 @@ $env:SWITCHIFY_CERTUM_CERT_THUMBPRINT = "<certum-certificate-thumbprint>"
101108
$env:SWITCHIFY_CERTUM_TIMESTAMP_URL = "http://time.certum.pl"
102109
```
103110

111+
### Release preflight
112+
113+
Before creating or pushing a release tag, the maintainer or agent must verify all of the following and stop if any check fails:
114+
115+
- Local `main` is clean and up to date with `origin/main`.
116+
- `package.json` version is the exact version being released.
117+
- The release tag is exactly `vX.Y.Z`, where `X.Y.Z` equals `package.json`.
118+
- The release issue and release PR are assigned to milestone `Release X.Y.Z`.
119+
- The milestone `Release X.Y.Z` exists and has no unrelated open issues.
120+
- The self-hosted runner with label `switchify-signing` is online and not busy.
121+
- The Certum signing certificate thumbprint is available out-of-band or through the configured repository variable.
122+
- The matching certificate exists in `Cert:\CurrentUser\My`, has a private key, and SimplySign is logged in.
123+
124+
Use commands like these for preflight checks. Do not print, document, or commit the real certificate thumbprint.
125+
126+
```powershell
127+
$packageVersion = node -p "require('./package.json').version"
128+
$expectedTag = "v$packageVersion"
129+
$expectedMilestone = "Release $packageVersion"
130+
131+
git status --short --branch
132+
git pull --ff-only
133+
134+
$milestones = gh api repos/switchifyapp/switchify-pc/milestones?state=all | ConvertFrom-Json
135+
$milestone = $milestones | Where-Object { $_.title -eq $expectedMilestone } | Select-Object -First 1
136+
if (-not $milestone) {
137+
throw "Expected milestone was not found: $expectedMilestone"
138+
}
139+
140+
$runner = (gh api repos/switchifyapp/switchify-pc/actions/runners | ConvertFrom-Json).runners |
141+
Where-Object { $_.labels.name -contains 'switchify-signing' } |
142+
Select-Object -First 1
143+
144+
if (-not $runner -or $runner.status -ne 'online' -or $runner.busy) {
145+
throw 'The switchify-signing runner is not ready.'
146+
}
147+
148+
$thumbprint = $env:SWITCHIFY_CERTUM_CERT_THUMBPRINT -replace '[^a-fA-F0-9]', ''
149+
if (-not $thumbprint) {
150+
throw 'SWITCHIFY_CERTUM_CERT_THUMBPRINT is not set in this shell. Do not hard-code it.'
151+
}
152+
153+
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert |
154+
Where-Object { $_.Thumbprint -eq $thumbprint } |
155+
Select-Object -First 1
156+
157+
if (-not $cert -or -not $cert.HasPrivateKey) {
158+
throw 'The Certum signing certificate is missing or has no private key.'
159+
}
160+
```
161+
162+
When preparing the next milestone, verify first and create only if missing:
163+
164+
```powershell
165+
$nextMilestone = "Release X.Y.Z"
166+
$milestones = gh api repos/switchifyapp/switchify-pc/milestones?state=all | ConvertFrom-Json
167+
$existing = $milestones | Where-Object { $_.title -eq $nextMilestone } | Select-Object -First 1
168+
169+
if (-not $existing) {
170+
gh api repos/switchifyapp/switchify-pc/milestones -f title=$nextMilestone
171+
}
172+
```
173+
174+
If the thumbprint is available only as a GitHub repository variable, the maintainer may verify that the variable exists without printing its value, then verify the local certificate with the thumbprint supplied privately.
175+
104176
The release workflow:
105177

106178
- installs dependencies with `npm ci`
@@ -136,6 +208,47 @@ git push origin vX.Y.Z
136208

137209
The workflow can also be dispatched manually by the maintainer with a `tag` input.
138210

211+
Do not push a release tag until the release PR with the matching version bump has merged to `main` and local `main` has been pulled.
212+
213+
Do not tag if:
214+
215+
- `package.json` does not match the intended tag.
216+
- The release issue or PR milestone does not match `Release X.Y.Z`.
217+
- The signing runner is offline or busy.
218+
- The Certum certificate cannot be verified locally.
219+
220+
After the release workflow succeeds:
221+
222+
1. Verify the GitHub Release exists for `vX.Y.Z`.
223+
2. Verify the release assets are present:
224+
- `Switchify-PC-Setup-X.Y.Z-x64.exe`
225+
- `latest.yml`
226+
- `builder-debug.yml`
227+
3. Verify there are no open issues in milestone `Release X.Y.Z`.
228+
4. Close milestone `Release X.Y.Z`.
229+
5. If issues remain open, do not close the milestone; report the blockers.
230+
231+
Use commands like these for post-release verification and milestone closure:
232+
233+
```powershell
234+
gh release view $expectedTag --repo switchifyapp/switchify-pc
235+
236+
$openIssues = gh issue list `
237+
--repo switchifyapp/switchify-pc `
238+
--milestone $expectedMilestone `
239+
--state open `
240+
--json number,title,state | ConvertFrom-Json
241+
242+
if ($openIssues.Count -gt 0) {
243+
throw "Milestone $expectedMilestone still has open issues."
244+
}
245+
246+
gh api "repos/switchifyapp/switchify-pc/milestones/$($milestone.number)" `
247+
-X PATCH `
248+
-f state=closed `
249+
--silent
250+
```
251+
139252
Do not:
140253

141254
- publish releases from contributor machines

0 commit comments

Comments
 (0)