Skip to content

Commit 6ce4e26

Browse files
authored
Add release engineering infrastructure (#3)
* Rename module to github.com/basecamp/hey-cli Enables `go install github.com/basecamp/hey-cli/cmd/hey@latest`. * Add build-time version injection and CLI surface support - internal/version: build-time Version/Commit/Date via ldflags - root.go: --version flag, hidden --agent flag for JSON CLI surface - client.go: User-Agent header from version.UserAgent() * Overhaul Makefile for full build, test, and release lifecycle Adds: build-pgo, fmt-check, vet, lint, tidy-check, race-test, vuln, secrets, replace-check, check (CI gate), security, release-check, bench/bench-cpu/bench-mem/bench-save/bench-compare, collect-profile, check-surface, check-surface-compat, tools. Includes check-toolchain guard for mise-managed Go installations. * Add GoReleaser configuration and release scripts GoReleaser: cross-platform builds (darwin/linux/windows/freebsd/openbsd), PGO via -pgo=auto, cosign keyless signing, conditional macOS notarization, Homebrew cask, Scoop, nfpm deb/rpm packaging. Scripts: release.sh (preflight + tag), publish-aur.sh (source-based AUR), install.sh (curl installer with checksum + cosign verification), collect-profile.sh (PGO from benchmarks), check-cli-surface.sh and check-cli-surface-diff.sh (surface snapshot + breaking change detection), sync-skills.sh (skill distribution to basecamp/skills). * Add CI workflows and repository configuration Workflows: test.yml (unit tests, lint, govulncheck, race detector), security.yml (gitleaks, Trivy, gosec, CodeQL, dependency review), release.yml (PGO, AI changelog, cosign, notarization, surface compat, AUR, skills sync), ai-labeler.yml (PR classification + breaking change detection), dependabot-auto-merge.yml. Config: .golangci.yml, .gitleaks.toml, .github/dependabot.yml, .github/release.yml (changelog categories), CodeQL config, AI prompts. * Fix lint issues in new code - Suppress unused MarkHidden/Encode return values - Use _ for unused agentHelpFunc args parameter - Exclude internal/version/ from revive var-naming * Fix all lint issues for clean golangci-lint gate - errorlint: wrap errors with %w instead of %v in auth package - errcheck: check server.Shutdown, type assertions, file cleanup returns - gosec: suppress false positives (G117 token fields, G115 fd cast, G204 browser/editor launch, G703 internal paths) - govet: eliminate variable shadowing in auth, client, config, editor, recordings - noctx: use NewRequestWithContext in client and TUI image fetcher, CommandContext in editor - nilerr: document intentional nil returns in auth status and raw JSON - prealloc: preallocate slices in entry parser - predeclared: rename shadowed `max` parameter - unused: remove dead limitJSONArray function and kittyImage type - exhaustive: annotate intentional partial switches - revive: add justification comments for blank image decoder imports - staticcheck: convert if-else chain to tagged switch in findImages - unparam: remove unused configDir parameter from migrateOldCredentials * Allow dependency-review to soft-fail without GHAS The dependency-review action requires GitHub Advanced Security (dependency graph) which may not be enabled on private repos. Use continue-on-error so it doesn't block PRs. * Address PR review feedback - tidy-check: use trap for reliable cleanup on failure/interrupt - check-surface-compat: fail when baseline build fails instead of silently skipping - agentHelpFunc: include inherited flags via InheritedFlags() so persistent flags appear in subcommand surface snapshots - install.sh: fail fast on missing checksum instead of warning - install.sh: fail on cosign verification failure with HEY_INSECURE_SKIP_COSIGN bypass * Move continue-on-error to step level for dependency-review Job-level continue-on-error makes the workflow pass but the check run still reports failure. Step-level continue-on-error makes the job itself report success. * Address second round of PR review feedback - agentHelpFunc: also visit PersistentFlags() so root-level persistent flags appear in the surface snapshot - publish-aur.sh: validate required env vars upfront, fix header comment - install.sh: tighten cosign certificate-identity-regexp to match only the release workflow * Fix bot name in publish-aur.sh to cli-release-bot * Address third round of PR review feedback - install.sh: use find to locate binary in extracted archive, handles both flat and nested archive layouts - test.yml: use go-version-file for security job to match other jobs - check-cli-surface-diff.sh: add usage check for missing arguments
1 parent af82ace commit 6ce4e26

66 files changed

Lines changed: 2352 additions & 172 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/codeql/codeql-config.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
queries:
2+
- uses: security-and-quality
3+
4+
query-filters:
5+
- exclude:
6+
kind: [diagnostic, metric]

‎.github/dependabot.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: github-actions
10+
directory: /
11+
schedule:
12+
interval: weekly
13+
open-pull-requests-limit: 10
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
messages:
2+
- role: system
3+
content: |
4+
You classify pull requests for release note categorization.
5+
Respond with exactly one word: bug, enhancement, or documentation.
6+
7+
- bug: corrects wrong behavior, broken defaults, incorrect error codes,
8+
retry/backoff defects, auth handling bugs, compatibility regressions.
9+
Test-only changes that fix assertions for previously-wrong behavior
10+
count as bug.
11+
- enhancement: new API coverage, new SDK features, new configuration
12+
options, new test coverage, generator/tooling improvements.
13+
If only generated files changed with no bug claim, default to
14+
enhancement.
15+
- documentation: README, CONTRIBUTING, SECURITY, or other docs-only
16+
changes with no runtime behavior change. SDK README updates that
17+
accompany code changes don't count — label the code change.
18+
19+
When a PR mixes categories: bug > enhancement > documentation.
20+
Prefer diff evidence over the PR title.
21+
model: openai/gpt-4o-mini
22+
modelParameters:
23+
maxCompletionTokens: 10
24+
temperature: 0
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
messages:
2+
- role: system
3+
content: |
4+
You analyze CLI tool diffs for breaking changes. A breaking change is:
5+
- Removal or rename of a CLI command or subcommand
6+
- Removal or rename of a flag (--flag)
7+
- Change in output format that would break scripts parsing the output
8+
- Change in exit codes
9+
- Removal of environment variable support
10+
11+
NOT breaking: adding new commands, adding new flags, internal refactors,
12+
test changes, documentation, adding new output fields.
13+
14+
Respond with a JSON object:
15+
{"breaking": true/false, "items": ["description of each breaking change"]}
16+
model: openai/gpt-4o-mini
17+
responseFormat: json_schema
18+
jsonSchema: |-
19+
{
20+
"name": "breaking_analysis",
21+
"strict": true,
22+
"schema": {
23+
"type": "object",
24+
"properties": {
25+
"breaking": { "type": "boolean" },
26+
"items": { "type": "array", "items": { "type": "string" } }
27+
},
28+
"required": ["breaking", "items"],
29+
"additionalProperties": false
30+
}
31+
}
32+
modelParameters:
33+
maxCompletionTokens: 500
34+
temperature: 0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
messages:
2+
- role: system
3+
content: |
4+
You write release summaries for a CLI tool. Given a list of commits and a
5+
diff, produce a short narrative overview of the release — NOT a categorized
6+
changelog (the detailed per-PR list is generated separately).
7+
8+
Rules:
9+
- Write 2-4 short paragraphs in plain prose, no bullet lists
10+
- Lead with the most important change; group related changes naturally
11+
- Flag any breaking changes prominently at the top with ⚠️
12+
- Use imperative voice ("Add", "Fix", not "Added", "Fixed")
13+
- No commit hashes, no PR numbers, no author attributions
14+
- No markdown headings — just paragraphs
15+
- Do NOT wrap output in code fences
16+
- Keep it under 15 lines
17+
model: openai/gpt-4o
18+
modelParameters:
19+
maxCompletionTokens: 1500
20+
temperature: 0.2

‎.github/release.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
changelog:
2+
categories:
3+
- title: Breaking Changes
4+
labels:
5+
- breaking
6+
- title: Features
7+
labels:
8+
- enhancement
9+
- feature
10+
- title: Bug Fixes
11+
labels:
12+
- bug
13+
- fix
14+
- title: Documentation
15+
labels:
16+
- documentation
17+
- title: Other Changes
18+
labels:
19+
- "*"

‎.github/workflows/ai-labeler.yml‎

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: Classify PR
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: classify-pr-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read
13+
issues: write
14+
models: read
15+
pull-requests: write
16+
17+
jobs:
18+
classify:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Build prompt
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: |
27+
PR=${{ github.event.pull_request.number }}
28+
gh pr diff "$PR" > /tmp/pr.diff
29+
gh pr view "$PR" --json title --jq .title > /tmp/pr-title.txt
30+
gh pr view "$PR" --json body --jq '.body // ""' > /tmp/pr-body.txt
31+
32+
{
33+
printf 'PR #%s: %s\n' "$PR" "$(cat /tmp/pr-title.txt)"
34+
echo ""
35+
cat /tmp/pr-body.txt
36+
echo ""
37+
echo "Diff (truncated):"
38+
head -c 100000 /tmp/pr.diff
39+
} > /tmp/user-message.txt
40+
41+
python3 -c "
42+
with open('.github/prompts/classify-pr.prompt.yml') as f:
43+
lines = f.readlines()
44+
with open('/tmp/user-message.txt') as f:
45+
user_msg = f.read()
46+
47+
insert_at = len(lines)
48+
for i, line in enumerate(lines):
49+
if i == 0:
50+
continue
51+
if line.strip() and not line[0].isspace():
52+
insert_at = i
53+
break
54+
55+
entry = [' - role: user\n', ' content: |\n']
56+
for ln in user_msg.splitlines():
57+
entry.append(' ' + ln + '\n')
58+
59+
lines[insert_at:insert_at] = entry
60+
with open('/tmp/prompt.yml', 'w') as f:
61+
f.writelines(lines)
62+
63+
try:
64+
import yaml
65+
doc = yaml.safe_load(open('/tmp/prompt.yml'))
66+
assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed'
67+
except ImportError:
68+
pass
69+
"
70+
71+
- name: Classify
72+
id: classify
73+
uses: actions/ai-inference@v2
74+
with:
75+
prompt-file: /tmp/prompt.yml
76+
77+
- name: Apply label
78+
env:
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |
81+
LABEL=$(echo "${{ steps.classify.outputs.response }}" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
82+
case "$LABEL" in
83+
bug|enhancement|documentation) ;;
84+
*) echo "Unexpected: $LABEL — skipping"; exit 0 ;;
85+
esac
86+
PR=${{ github.event.pull_request.number }}
87+
CURRENT=$(gh pr view "$PR" --json labels --jq '.labels[].name')
88+
for L in bug enhancement documentation; do
89+
if [ "$L" != "$LABEL" ] && echo "$CURRENT" | grep -qx "$L"; then
90+
gh pr edit "$PR" --remove-label "$L" 2>/dev/null || true
91+
fi
92+
done
93+
if ! echo "$CURRENT" | grep -qx "$LABEL"; then
94+
gh pr edit "$PR" --add-label "$LABEL" 2>/dev/null || true
95+
fi
96+
97+
breaking:
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Build prompt
103+
id: cmd-diff
104+
env:
105+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
run: |
107+
PR=${{ github.event.pull_request.number }}
108+
109+
PATTERNS=(
110+
"internal/cmd/*.go"
111+
)
112+
gh pr diff "$PR" > /tmp/full.diff
113+
114+
python3 -c "
115+
import sys, re, fnmatch
116+
diff = open('/tmp/full.diff').read()
117+
patterns = sys.argv[1:]
118+
sections = re.split(r'(?=^diff --git)', diff, flags=re.MULTILINE)
119+
for s in sections:
120+
m = re.match(r'diff --git a/(\S+)', s)
121+
if m:
122+
path = m.group(1)
123+
if any(fnmatch.fnmatch(path, p) for p in patterns):
124+
sys.stdout.write(s)
125+
" "${PATTERNS[@]}" > /tmp/cmd.diff
126+
127+
if [ ! -s /tmp/cmd.diff ]; then
128+
echo "skip=true" >> $GITHUB_OUTPUT
129+
else
130+
TITLE=$(gh pr view "$PR" --json title --jq .title)
131+
132+
{
133+
printf 'PR #%s: %s\n' "$PR" "$TITLE"
134+
echo ""
135+
echo "Diff of CLI command surface files:"
136+
head -c 100000 /tmp/cmd.diff
137+
} > /tmp/user-message.txt
138+
139+
python3 -c "
140+
with open('.github/prompts/detect-breaking.prompt.yml') as f:
141+
lines = f.readlines()
142+
with open('/tmp/user-message.txt') as f:
143+
user_msg = f.read()
144+
145+
insert_at = len(lines)
146+
for i, line in enumerate(lines):
147+
if i == 0:
148+
continue
149+
if line.strip() and not line[0].isspace():
150+
insert_at = i
151+
break
152+
153+
entry = [' - role: user\n', ' content: |\n']
154+
for ln in user_msg.splitlines():
155+
entry.append(' ' + ln + '\n')
156+
157+
lines[insert_at:insert_at] = entry
158+
with open('/tmp/prompt.yml', 'w') as f:
159+
f.writelines(lines)
160+
161+
try:
162+
import yaml
163+
doc = yaml.safe_load(open('/tmp/prompt.yml'))
164+
assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed'
165+
except ImportError:
166+
pass
167+
"
168+
echo "skip=false" >> $GITHUB_OUTPUT
169+
fi
170+
171+
- name: Detect breaking changes
172+
if: steps.cmd-diff.outputs.skip != 'true'
173+
id: detect
174+
uses: actions/ai-inference@v2
175+
with:
176+
prompt-file: /tmp/prompt.yml
177+
178+
- name: Apply breaking label
179+
if: steps.cmd-diff.outputs.skip != 'true'
180+
env:
181+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182+
run: |
183+
RESPONSE_FILE="${{ steps.detect.outputs.response-file }}"
184+
if [ -z "$RESPONSE_FILE" ] || [ ! -f "$RESPONSE_FILE" ]; then
185+
echo "::warning::Model response file is missing; skipping breaking label."
186+
exit 0
187+
fi
188+
if ! jq empty "$RESPONSE_FILE" 2>/dev/null; then
189+
echo "::warning::Model response is not valid JSON; skipping breaking label."
190+
echo "## Breaking change detection failed" >> "$GITHUB_STEP_SUMMARY"
191+
echo "Model returned invalid JSON. Breaking label was **not** applied." >> "$GITHUB_STEP_SUMMARY"
192+
if [ -s "$RESPONSE_FILE" ]; then
193+
echo '```' >> "$GITHUB_STEP_SUMMARY"
194+
cat "$RESPONSE_FILE" >> "$GITHUB_STEP_SUMMARY"
195+
echo '```' >> "$GITHUB_STEP_SUMMARY"
196+
fi
197+
exit 0
198+
fi
199+
BREAKING=$(jq -r '.breaking' "$RESPONSE_FILE")
200+
PR=${{ github.event.pull_request.number }}
201+
202+
if [ "$BREAKING" = "true" ]; then
203+
ITEMS=$(jq -r '.items[]' "$RESPONSE_FILE" | sed 's/^/- /')
204+
gh label create breaking --color "B60205" 2>/dev/null || true
205+
gh pr edit "$PR" --add-label "breaking"
206+
207+
{
208+
echo "⚠️ **Potential breaking changes detected:**"
209+
echo ""
210+
echo "$ITEMS"
211+
echo ""
212+
echo "_Review carefully before merging. Consider a major version bump._"
213+
} > /tmp/breaking-comment.md
214+
215+
EXISTING=$(gh pr view "$PR" --json comments --jq '.comments[] | select(.body | startswith("⚠️ **Potential breaking")) | .id' | head -1)
216+
if [ -n "$EXISTING" ]; then
217+
gh api graphql -f query="mutation { updateIssueComment(input: {id: \"$EXISTING\", body: $(jq -Rs . /tmp/breaking-comment.md)}) { issueComment { id } } }"
218+
else
219+
gh pr comment "$PR" --body-file /tmp/breaking-comment.md
220+
fi
221+
else
222+
gh pr edit "$PR" --remove-label "breaking" 2>/dev/null || true
223+
fi
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Dependabot Auto-Merge
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
9+
jobs:
10+
auto-merge:
11+
runs-on: ubuntu-latest
12+
if: github.actor == 'dependabot[bot]'
13+
steps:
14+
- name: Fetch Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v2
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Approve patch and minor updates (excluding actions)
21+
if: >-
22+
(
23+
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
24+
steps.metadata.outputs.update-type == 'version-update:semver-minor'
25+
) &&
26+
steps.metadata.outputs.package-ecosystem != 'github_actions'
27+
run: gh pr review --approve "$PR_URL"
28+
env:
29+
PR_URL: ${{ github.event.pull_request.html_url }}
30+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Enable auto-merge for patch and minor updates (excluding actions)
33+
if: >-
34+
(
35+
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
36+
steps.metadata.outputs.update-type == 'version-update:semver-minor'
37+
) &&
38+
steps.metadata.outputs.package-ecosystem != 'github_actions'
39+
run: gh pr merge --auto --squash "$PR_URL"
40+
env:
41+
PR_URL: ${{ github.event.pull_request.html_url }}
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)