-
Notifications
You must be signed in to change notification settings - Fork 32
150 lines (132 loc) · 5.47 KB
/
finalize-release.yml
File metadata and controls
150 lines (132 loc) · 5.47 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
name: Finalize GPULlama3 Release
on:
pull_request:
types: [closed]
branches: [main]
workflow_dispatch:
inputs:
version:
description: 'Release version to tag (e.g., 0.2.3)'
required: true
type: string
jobs:
create-release-tag:
# Run when release PR merges OR manual trigger
if: |
(github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')) ||
github.event_name == 'workflow_dispatch'
runs-on: [self-hosted, Linux, x64]
permissions:
contents: write
timeout-minutes: 10
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
BRANCH="${{ github.event.pull_request.head.ref }}"
echo "version=${BRANCH#release/}" >> $GITHUB_OUTPUT
fi
- name: Checkout main
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create and push tag
run: |
VERSION="${{ steps.get_version.outputs.version }}"
git tag -a "v${VERSION}" -m "Release ${VERSION}"
git push origin "v${VERSION}"
echo "✅ Created tag v${VERSION}"
- name: Extract changelog for release notes
id: changelog
run: |
VERSION="${{ steps.get_version.outputs.version }}"
CHANGELOG_FILE="CHANGELOG.md"
if [ -f "$CHANGELOG_FILE" ]; then
# Extract section for this version
awk -v ver="## \\[${VERSION}\\]" '
$0 ~ ver { found=1; next }
found && /^## \[/ { exit }
found { print }
' "$CHANGELOG_FILE" > /tmp/release_notes.txt
if [ -s /tmp/release_notes.txt ]; then
echo "Found changelog section for ${VERSION}"
else
echo "See CHANGELOG.md for details." > /tmp/release_notes.txt
fi
else
echo "See commit history for changes." > /tmp/release_notes.txt
fi
- name: Create GitHub Release
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const version = '${{ steps.get_version.outputs.version }}';
let releaseNotes;
try {
releaseNotes = fs.readFileSync('/tmp/release_notes.txt', 'utf8').trim();
if (!releaseNotes) {
releaseNotes = `Release ${version}`;
}
} catch (e) {
releaseNotes = `Release ${version}`;
}
// Add installation instructions
releaseNotes += `\n\n---\n\n### 📦 Installation\n\n`;
releaseNotes += `**Maven**\n\`\`\`xml\n<dependency>\n <groupId>io.github.beehive-lab</groupId>\n <artifactId>gpu-llama3</artifactId>\n <version>${version}</version>\n</dependency>\n\`\`\`\n\n`;
releaseNotes += `**Gradle**\n\`\`\`groovy\nimplementation 'io.github.beehive-lab:gpu-llama3:${version}'\n\`\`\`\n\n`;
releaseNotes += `---\n\n📖 [Documentation](https://github.com/beehive-lab/GPULlama3.java#readme) | 🔗 [Maven Central](https://central.sonatype.com/artifact/io.github.beehive-lab/gpu-llama3/${version})`;
const { data: release } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${version}`,
name: `GPULlama3.java ${version}`,
body: releaseNotes,
draft: false,
prerelease: false
});
console.log(`✅ Created release: ${release.html_url}`);
- name: Summary
run: |
VERSION="${{ steps.get_version.outputs.version }}"
echo "## 🎉 Release v${VERSION} Finalized" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Step | Status |" >> $GITHUB_STEP_SUMMARY
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Tag created | ✅ v${VERSION} |" >> $GITHUB_STEP_SUMMARY
echo "| GitHub Release | ✅ Created |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🔄 Next:" >> $GITHUB_STEP_SUMMARY
echo "**Deploy to Maven Central** workflow will trigger automatically" >> $GITHUB_STEP_SUMMARY
cleanup-branch:
needs: create-release-tag
runs-on: [self-hosted, Linux, x64]
permissions:
contents: write
if: github.event_name == 'pull_request'
steps:
- name: Delete release branch
uses: actions/github-script@v7
with:
script: |
const branch = '${{ github.event.pull_request.head.ref }}';
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${branch}`
});
console.log(`✅ Deleted branch: ${branch}`);
} catch (e) {
console.log(`Could not delete branch: ${e.message}`);
}