-
-
Notifications
You must be signed in to change notification settings - Fork 8
162 lines (141 loc) · 5.63 KB
/
release.yml
File metadata and controls
162 lines (141 loc) · 5.63 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
tag:
name: Bump version & create tag
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.bump.outputs.new_tag }}
previous_tag: ${{ steps.bump.outputs.previous_tag }}
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ secrets.RELEASE_PAT }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get previous tag
id: prev_tag
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)
echo "tag=$PREV_TAG" >> "$GITHUB_OUTPUT"
- name: Check for commits since last release
run: |
COMMIT_COUNT=$(git rev-list ${{ steps.prev_tag.outputs.tag }}..HEAD --count)
if [ "$COMMIT_COUNT" -eq 0 ]; then
echo "No commits since ${{ steps.prev_tag.outputs.tag }}, nothing to release."
exit 1
fi
echo "$COMMIT_COUNT commit(s) since ${{ steps.prev_tag.outputs.tag }}"
- name: Bump version
id: bump
run: |
npm version ${{ inputs.version_type }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
NEW_TAG="v${NEW_VERSION}"
git add package.json
git commit -m "${NEW_VERSION}"
git tag -a "${NEW_TAG}" -m "${NEW_TAG}"
git push origin main --follow-tags
echo "new_tag=${NEW_TAG}" >> "$GITHUB_OUTPUT"
echo "previous_tag=${{ steps.prev_tag.outputs.tag }}" >> "$GITHUB_OUTPUT"
release:
name: Generate release notes & create release
needs: tag
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.new_tag }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Jazz
run: bun install -g jazz-ai
- name: Setup Jazz agent and workflow
env:
NEW_TAG: ${{ needs.tag.outputs.new_tag }}
PREVIOUS_TAG: ${{ needs.tag.outputs.previous_tag }}
REPO: ${{ github.repository }}
WORKSPACE: ${{ github.workspace }}
run: |
mkdir -p "$HOME/.jazz/agents" workflows/release-notes
cp .github/jazz/agents/release-notes.json "$HOME/.jazz/agents/"
sed -e "s/__NEW_TAG__/$NEW_TAG/g" -e "s/__PREVIOUS_TAG__/$PREVIOUS_TAG/g" -e "s|__REPO__|$REPO|g" -e "s|__WORKSPACE__|$WORKSPACE|g" \
.github/jazz/workflows/release-notes/WORKFLOW.md > workflows/release-notes/WORKFLOW.md
echo "--- Substituted workflow ---"
cat workflows/release-notes/WORKFLOW.md
- name: Generate release notes
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
CI: "true"
JAZZ_DISABLE_CATCH_UP: "1"
run: |
jazz --output raw workflow run release-notes --auto-approve --agent release-notes \
2>&1 | tee /tmp/jazz-release-notes.txt
- name: Create GitHub release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.RELEASE_PAT }}
script: |
const fs = require('fs');
const output = fs.readFileSync('/tmp/jazz-release-notes.txt', 'utf8');
// Prefer the agent's four-backtick fence; fall back to a
// last-occurrence scan of the three-backtick form so inner
// code samples don't truncate the wrapper.
const extractFencedMarkdown = (text) => {
const fourFence = text.match(/````markdown\s*\n([\s\S]*?)\n?````/);
if (fourFence) return fourFence[1].trim();
const open = text.lastIndexOf('```markdown');
if (open < 0) return null;
const after = text.slice(open + '```markdown'.length);
const close = after.lastIndexOf('```');
if (close < 0) return null;
return after.slice(0, close).trim();
};
let releaseBody = extractFencedMarkdown(output);
if (!releaseBody) {
console.log('Jazz release notes unavailable — falling back to GitHub auto-generated notes.');
const generated = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ needs.tag.outputs.new_tag }}',
previous_tag_name: '${{ needs.tag.outputs.previous_tag }}',
});
releaseBody = generated.data.body || '_Release notes could not be generated. See commit history for changes._';
}
const tag = '${{ needs.tag.outputs.new_tag }}';
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
body: releaseBody,
draft: false,
prerelease: false
});
console.log(`Release ${tag} created successfully.`);