Skip to content

Commit 12b8f65

Browse files
chore: add version-change release workflow
Co-authored-by: Cursor <cursoragent@cursor.com>
0 parents  commit 12b8f65

3 files changed

Lines changed: 129 additions & 0 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: release on version change
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- package.json
9+
workflow_dispatch:
10+
11+
permissions:
12+
id-token: write
13+
contents: write
14+
pull-requests: write
15+
issues: write
16+
actions: read
17+
checks: read
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 0
27+
28+
- name: detect version change
29+
id: version
30+
uses: actions/github-script@v8
31+
with:
32+
script: |
33+
const fs = require("node:fs");
34+
const childProcess = require("node:child_process");
35+
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
36+
const current = String(packageJson.version ?? "");
37+
let previous = "";
38+
39+
try {
40+
const previousPackageJson = childProcess.execSync("git show HEAD^:package.json", {
41+
encoding: "utf8",
42+
});
43+
const previousPackage = JSON.parse(previousPackageJson);
44+
previous = String(previousPackage.version ?? "");
45+
} catch {}
46+
47+
const changed = previous === "" || current !== previous;
48+
core.setOutput("current", current);
49+
core.setOutput("previous", previous);
50+
core.setOutput("changed", String(changed));
51+
core.info(`current=${current} previous=${previous} changed=${changed}`);
52+
53+
- name: check for existing release tag
54+
id: release_exists
55+
if: steps.version.outputs.changed == 'true'
56+
uses: actions/github-script@v8
57+
with:
58+
script: |
59+
const tag = "v${{ steps.version.outputs.current }}";
60+
let exists = false;
61+
try {
62+
await github.rest.repos.getReleaseByTag({
63+
owner: context.repo.owner,
64+
repo: context.repo.repo,
65+
tag,
66+
});
67+
exists = true;
68+
} catch (error) {
69+
if (error.status !== 404) {
70+
throw error;
71+
}
72+
}
73+
core.setOutput("exists", String(exists));
74+
core.info(`tag=${tag} exists=${exists}`);
75+
76+
- name: generate changelog with pullfrog
77+
id: changelog
78+
if: steps.version.outputs.changed == 'true' && steps.release_exists.outputs.exists != 'true'
79+
uses: pullfrog/pullfrog@main
80+
with:
81+
agent: codex
82+
effort: auto
83+
timeout: 20m
84+
prompt: |
85+
Generate the release changelog markdown for version v${{ steps.version.outputs.current }}.
86+
Previous version from package.json is "${{ steps.version.outputs.previous }}".
87+
88+
Requirements:
89+
- Read git history and summarize notable changes.
90+
- Keep output concise and factual.
91+
- Output valid markdown for a GitHub Release body.
92+
- Include these exact headings:
93+
## highlights
94+
## changes
95+
- Do not wrap the output in code fences.
96+
- call gh_pullfrog/set_output exactly once with the full markdown body.
97+
env:
98+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
99+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
100+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
101+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
102+
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
103+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
104+
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
105+
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
106+
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
107+
108+
- name: create GitHub release
109+
if: steps.version.outputs.changed == 'true' && steps.release_exists.outputs.exists != 'true'
110+
uses: softprops/action-gh-release@v2
111+
with:
112+
tag_name: v${{ steps.version.outputs.current }}
113+
name: v${{ steps.version.outputs.current }}
114+
body: ${{ steps.changelog.outputs.result }}

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# release test repo
2+
3+
this repository validates a CI workflow that:
4+
5+
- detects `package.json` version changes on `main`
6+
- asks `pullfrog/pullfrog` to generate a changelog
7+
- requires the agent to call `gh_pullfrog/set_output`
8+
- creates a GitHub release with the generated changelog body

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "release-test-set-output-20260217162223",
3+
"private": true,
4+
"version": "0.1.0",
5+
"description": "e2e test repo for pullfrog changelog releases",
6+
"license": "MIT"
7+
}

0 commit comments

Comments
 (0)