1- # .github/workflows/promote-release.yml
2-
31name : Promote Release
42
53on :
@@ -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 {
0 commit comments