chore(go): route release notes through vociferate

This commit is contained in:
Micheal Wilkinson
2026-03-21 14:33:53 +00:00
parent 9dc28e8229
commit 92f76fd19f
5 changed files with 198 additions and 16 deletions

View File

@@ -36,6 +36,19 @@ outputs:
runs:
using: composite
steps:
- name: Resolve vociferate binary metadata
id: resolve-binary
shell: bash
env:
ACTION_REF: ${{ github.action_ref }}
ACTION_REPOSITORY: ${{ github.action_repository }}
CACHE_TOKEN: ${{ env.VOCIFERATE_CACHE_TOKEN }}
SERVER_URL: ${{ github.server_url }}
RUNNER_ARCH: ${{ runner.arch }}
RUNNER_TEMP: ${{ runner.temp }}
run: |
bash "$GITHUB_ACTION_PATH/../script/resolve-vociferate-runtime.sh"
- name: Resolve release version
id: resolve-version
shell: bash
@@ -63,9 +76,53 @@ runs:
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$normalized" >> "$GITHUB_OUTPUT"
- name: Extract release notes from changelog
id: extract-notes
- name: Setup Go
if: steps.resolve-binary.outputs.use_binary != 'true'
uses: actions/setup-go@v5
with:
go-version: '1.26.1'
cache: true
cache-dependency-path: ${{ steps.resolve-binary.outputs.source_root }}/go.sum
- name: Restore cached vociferate binary
id: cache-vociferate
if: steps.resolve-binary.outputs.use_binary == 'true'
uses: actions/cache@v4
with:
path: ${{ steps.resolve-binary.outputs.cache_dir }}
key: vociferate-${{ steps.resolve-binary.outputs.cache_token }}-linux-${{ runner.arch }}
- name: Download vociferate binary
if: steps.resolve-binary.outputs.use_binary == 'true' && steps.cache-vociferate.outputs.cache-hit != 'true'
shell: bash
env:
TOKEN: ${{ github.token }}
ASSET_URL: ${{ steps.resolve-binary.outputs.asset_url }}
BINARY_PATH: ${{ steps.resolve-binary.outputs.binary_path }}
run: |
bash "${{ steps.resolve-binary.outputs.source_root }}/script/download-vociferate-binary.sh"
- name: Extract release notes from binary
id: extract-notes-binary
if: steps.resolve-binary.outputs.use_binary == 'true'
shell: bash
env:
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
CHANGELOG: ${{ inputs.changelog != '' && inputs.changelog || 'CHANGELOG.md' }}
RELEASE_VERSION: ${{ steps.resolve-version.outputs.version }}
RUNNER_TEMP: ${{ runner.temp }}
run: |
set -euo pipefail
notes_file="${RUNNER_TEMP}/release-notes.md"
"$VOCIFERATE_BIN" --print-release-notes --version "$RELEASE_VERSION" --root "$GITHUB_WORKSPACE" --changelog "$CHANGELOG" > "$notes_file"
printf 'notes_file=%s\n' "$notes_file" >> "$GITHUB_OUTPUT"
- name: Extract release notes from source
id: extract-notes-source
if: steps.resolve-binary.outputs.use_binary != 'true'
shell: bash
working-directory: ${{ steps.resolve-binary.outputs.source_root }}
env:
CHANGELOG: ${{ inputs.changelog != '' && inputs.changelog || 'CHANGELOG.md' }}
RELEASE_VERSION: ${{ steps.resolve-version.outputs.version }}
@@ -73,22 +130,25 @@ runs:
run: |
set -euo pipefail
release_notes="$(awk -v version="$RELEASE_VERSION" '
$0 ~ "^## \\[" version "\\]" {capture=1}
capture {
if ($0 ~ "^## \\[" && $0 !~ "^## \\[" version "\\]") exit
print
}
' "$CHANGELOG")"
notes_file="${RUNNER_TEMP}/release-notes.md"
go run ./cmd/vociferate --print-release-notes --version "$RELEASE_VERSION" --root "$GITHUB_WORKSPACE" --changelog "$CHANGELOG" > "$notes_file"
printf 'notes_file=%s\n' "$notes_file" >> "$GITHUB_OUTPUT"
if [[ -z "${release_notes//[[:space:]]/}" ]]; then
echo "Release notes section for ${RELEASE_VERSION} was not found in ${CHANGELOG}" >&2
exit 1
- name: Finalize release notes file
id: extract-notes
shell: bash
env:
NOTES_FILE_BINARY: ${{ steps.extract-notes-binary.outputs.notes_file }}
NOTES_FILE_SOURCE: ${{ steps.extract-notes-source.outputs.notes_file }}
run: |
set -euo pipefail
notes_file="$NOTES_FILE_BINARY"
if [[ -z "$notes_file" ]]; then
notes_file="$NOTES_FILE_SOURCE"
fi
notes_file="${RUNNER_TEMP}/release-notes.md"
printf '%s\n' "$release_notes" > "$notes_file"
echo "notes_file=$notes_file" >> "$GITHUB_OUTPUT"
printf 'notes_file=%s\n' "$notes_file" >> "$GITHUB_OUTPUT"
- name: Create or update release
id: create-release