Skip to content

Commit 078a769

Browse files
committed
ci: include checksums and commit messages in releases
- Generate promoted release .sha256 assets after jar renaming - Upload promoted jar checksums to GitHub releases - Mention promoted checksums in release notes - Include full commit messages in build release notes
1 parent 7b38259 commit 078a769

3 files changed

Lines changed: 141 additions & 19 deletions

File tree

.github/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
- internal
6+
authors:
7+
- github-actions[bot]
8+
9+
categories:
10+
- title: Added
11+
labels:
12+
- feature
13+
- enhancement
14+
15+
- title: Fixed
16+
labels:
17+
- bug
18+
- fix
19+
20+
- title: Changed
21+
labels:
22+
- change
23+
- refactor
24+
- improvement
25+
26+
- title: Updater and Release
27+
labels:
28+
- updater
29+
- release
30+
- ci
31+
32+
- title: Documentation
33+
labels:
34+
- documentation
35+
36+
- title: Other Changes
37+
labels:
38+
- "*"

.github/workflows/promote-release.yml

Lines changed: 86 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# .github/workflows/promote-release.yml
2-
31
name: Promote Release
42

53
on:
@@ -156,25 +154,104 @@ jobs:
156154
promoted_jar="dist/promoted/HeadDB-${{ steps.meta.outputs.target_version }}.jar"
157155
cp "${jars[0]}" "$promoted_jar"
158156
157+
promoted_sha="${promoted_jar}.sha256"
158+
159+
(
160+
cd "$(dirname "$promoted_jar")"
161+
sha256sum "$(basename "$promoted_jar")" > "$(basename "$promoted_sha")"
162+
)
163+
159164
echo "jar=${promoted_jar}" >> "$GITHUB_OUTPUT"
165+
echo "sha=${promoted_sha}" >> "$GITHUB_OUTPUT"
166+
167+
- name: Resolve previous public release tag
168+
id: previous
169+
shell: bash
170+
env:
171+
GH_TOKEN: ${{ github.token }}
172+
run: |
173+
set -euo pipefail
174+
175+
current_tag="${{ steps.meta.outputs.target_tag }}"
176+
177+
previous_tag="$(
178+
gh release list \
179+
--repo "${GITHUB_REPOSITORY}" \
180+
--limit 100 \
181+
--json tagName,isDraft,publishedAt \
182+
--jq '
183+
[
184+
.[]
185+
| select(.isDraft == false)
186+
| select(.tagName != "'"${current_tag}"'")
187+
| select(.tagName | contains("+build.") | not)
188+
]
189+
| sort_by(.publishedAt)
190+
| reverse
191+
| .[0].tagName // ""
192+
'
193+
)"
160194
161-
- name: Create release notes
195+
echo "tag=${previous_tag}" >> "$GITHUB_OUTPUT"
196+
197+
if [[ -n "$previous_tag" ]]; then
198+
echo "Previous public release: ${previous_tag}"
199+
else
200+
echo "No previous public release found."
201+
fi
202+
203+
- name: Generate release notes
204+
id: notes
162205
shell: bash
206+
env:
207+
GH_TOKEN: ${{ github.token }}
163208
run: |
164209
set -euo pipefail
165210
166-
cat > release-notes.md <<'EOF'
167-
HeadDB ${{ steps.meta.outputs.target_version }}
211+
args=(
212+
repos/${GITHUB_REPOSITORY}/releases/generate-notes
213+
--method POST
214+
--field tag_name="${{ steps.meta.outputs.target_tag }}"
215+
--field target_commitish="${{ steps.meta.outputs.source_commit }}"
216+
)
217+
218+
if [[ -n "${{ steps.previous.outputs.tag }}" ]]; then
219+
args+=(--field previous_tag_name="${{ steps.previous.outputs.tag }}")
220+
fi
221+
222+
if gh api "repos/${GITHUB_REPOSITORY}/contents/.github/release.yml?ref=${{ steps.meta.outputs.source_commit }}" >/dev/null 2>&1; then
223+
args+=(--field configuration_file_path=".github/release.yml")
224+
elif gh api "repos/${GITHUB_REPOSITORY}/contents/.github/release.yaml?ref=${{ steps.meta.outputs.source_commit }}" >/dev/null 2>&1; then
225+
args+=(--field configuration_file_path=".github/release.yaml")
226+
fi
227+
228+
gh api "${args[@]}" > generated-release-notes.json
229+
230+
jq -r '.body // ""' generated-release-notes.json > generated-body.md
231+
232+
cat > release-notes.md <<EOF
233+
## HeadDB ${{ steps.meta.outputs.target_version }}
168234
169235
This release promotes an already-built GitHub release artifact.
170236
171237
Source build: ${{ steps.meta.outputs.source_tag }}
172238
Source release: ${{ steps.meta.outputs.source_url }}
173239
Source commit: ${{ steps.meta.outputs.source_commit }}
174240
175-
The attached jar is the promoted jar from the source build release.
241+
The attached jar and .sha256 checksum are promoted from the source build release.
242+
176243
EOF
177244
245+
cat generated-body.md >> release-notes.md
246+
247+
delimiter="RELEASE_NOTES_$(date +%s)_${RANDOM}"
248+
249+
{
250+
echo "body<<${delimiter}"
251+
cat release-notes.md
252+
echo "${delimiter}"
253+
} >> "$GITHUB_OUTPUT"
254+
178255
- name: Create promoted GitHub release
179256
shell: bash
180257
env:
@@ -185,6 +262,7 @@ jobs:
185262
args=(
186263
"${{ steps.meta.outputs.target_tag }}"
187264
"${{ steps.asset.outputs.jar }}"
265+
"${{ steps.asset.outputs.sha }}"
188266
--repo "${GITHUB_REPOSITORY}"
189267
--target "${{ steps.meta.outputs.source_commit }}"
190268
--title "HeadDB ${{ steps.meta.outputs.target_version }}"
@@ -206,12 +284,7 @@ jobs:
206284
version: ${{ steps.meta.outputs.target_version }}
207285
name: HeadDB ${{ steps.meta.outputs.target_version }}
208286
channel: ${{ steps.meta.outputs.modrinth_channel }}
209-
changelog: |
210-
HeadDB ${{ steps.meta.outputs.target_version }}
211-
212-
Promoted from ${{ steps.meta.outputs.source_tag }}.
213-
214-
Source release: ${{ steps.meta.outputs.source_url }}
287+
changelog: ${{ steps.notes.outputs.body }}
215288
loaders: |-
216289
paper
217290
folia
@@ -229,12 +302,7 @@ jobs:
229302
slug: ${{ vars.HANGAR_PROJECT_SLUG }}
230303
version: ${{ steps.meta.outputs.target_version }}
231304
channel: ${{ steps.meta.outputs.hangar_channel }}
232-
description: |
233-
HeadDB ${{ steps.meta.outputs.target_version }}
234-
235-
Promoted from ${{ steps.meta.outputs.source_tag }}.
236-
237-
Source release: ${{ steps.meta.outputs.source_url }}
305+
description: ${{ steps.notes.outputs.body }}
238306
files: |-
239307
[
240308
{

.github/workflows/release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ jobs:
114114
echo "jar=${jar_name}" >> "$GITHUB_OUTPUT"
115115
echo "sha=${jar_name}.sha256" >> "$GITHUB_OUTPUT"
116116
117+
- name: Create build release notes
118+
shell: bash
119+
run: |
120+
set -euo pipefail
121+
122+
{
123+
echo "## HeadDB ${{ steps.version.outputs.build_version }}"
124+
echo
125+
echo "Build from commit: ${GITHUB_SHA}"
126+
echo
127+
echo "### Commit message"
128+
echo
129+
git log -1 --pretty=format:%s%n%n%b
130+
echo
131+
} > release-notes.md
132+
117133
- name: Create GitHub Release
118134
env:
119135
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -132,5 +148,5 @@ jobs:
132148
"${{ steps.assets.outputs.sha }}" \
133149
--target "${GITHUB_SHA}" \
134150
--title "HeadDB ${{ steps.version.outputs.build_version }}" \
135-
--notes "Build ${{ steps.version.outputs.build_version }} from commit ${GITHUB_SHA}." \
151+
--notes-file release-notes.md \
136152
${prerelease_flag}

0 commit comments

Comments
 (0)