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