Skip to content

ci: generate release notes from commit history; v0.6.1 #22

ci: generate release notes from commit history; v0.6.1

ci: generate release notes from commit history; v0.6.1 #22

Workflow file for this run

# Build and release the core on a version tag.
# git tag v0.3.0 && git push origin v0.3.0 -> release
# git tag v0.3.0-beta && git push origin v0.3.0-beta -> pre-release
# The release description is generated from the commit subjects since the
# previous tag (previous stable tag for a stable release; previous tag of any
# kind for a pre-release). Keep commit subjects changelog-worthy.
# Repo setting: Actions -> Workflow permissions -> "Read and write".
name: Build & Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history + tags, so the changelog step can diff against the previous tag
- name: Compile bitstream
run: |
docker run --rm -v "${{ github.workspace }}:/build" -w /build \
raetro/quartus:21.1 \
quartus_sh --flow compile projects/snes_pocket.qpf
sudo chown -R "$USER" projects/output_files
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: quartus-output
path: projects/output_files/
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Convert assets
# loader.bin is committed (rebuild locally with scripts/build-loader.sh
# when support/mk3_loader.asm changes).
run: |
python3 -m pip install --quiet pillow
scripts/build-icon-image.sh
- name: Package core
run: scripts/build-release.sh
- name: Upload core artifact
uses: actions/upload-artifact@v4
with:
name: core-zip
path: release/*.zip
- name: Generate release notes from commits
if: startsWith(github.ref, 'refs/tags/')
run: |
set -euo pipefail
CURRENT="${GITHUB_REF_NAME}"
# Pick the tag to diff against:
# stable (no "-") -> the previous stable release (skip pre-releases)
# pre-release -> the immediately preceding tag of any kind
case "$CURRENT" in
*-*) PREV="$(git describe --tags --abbrev=0 "${CURRENT}^" 2>/dev/null || true)" ;;
*) PREV="$(git tag --list 'v[0-9]*' --sort=-version:refname \
| grep -v '[-]' | grep -vxF "$CURRENT" | head -n1)" ;;
esac
{
echo "## Pro Action Replay MK3 — ${CURRENT}"
echo ""
if [ -n "${PREV}" ]; then
echo "Changes since ${PREV}:"
echo ""
RANGE="${PREV}..${CURRENT}"
else
echo "Initial release."
echo ""
RANGE="${CURRENT}"
fi
# one bullet per commit subject; drop merges and version-bump
# noise, then collapse duplicate subjects (kept in first-seen order)
git log --no-merges --pretty=format:'- %s' "${RANGE}" \
| grep -ivE '^- (bump version|merge )' \
| awk '!seen[$0]++' || true
echo ""
if [ -n "${PREV}" ]; then
echo ""
echo "**Full changelog:** https://github.com/${GITHUB_REPOSITORY}/compare/${PREV}...${CURRENT}"
fi
} > release_notes.md
echo "----- generated release notes -----"
cat release_notes.md
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: release/*.zip
prerelease: ${{ contains(github.ref_name, '-') }}
body_path: release_notes.md