show diffs in dev releases

This commit is contained in:
proddy
2026-09-18 14:43:51 +02:00
parent 8bc2aaa9c1
commit 755dc17b0d
2 changed files with 97 additions and 0 deletions
+25
View File
@@ -29,6 +29,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install pnpm
run: npm install -g pnpm
@@ -39,6 +41,13 @@ jobs:
version=`grep -E '^#define EMSESP_APP_VERSION' ./src/emsesp_version.h | awk -F'"' '{print $2}'`
echo "VERSION=$version" >> $GITHUB_OUTPUT
# must run before the release moves the 'latest' tag to this build
- name: Find the previous dev release
id: previous
run: |
prev=`git rev-parse -q --verify 'refs/tags/latest^{commit}' || git describe --tags --abbrev=0 --match 'v*'`
echo "REF=$prev" >> $GITHUB_OUTPUT
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
@@ -66,12 +75,28 @@ jobs:
with:
commit_message: "chore: update generated files for v${{steps.build_info.outputs.VERSION}}"
# an empty body falls back to the commit list generated by the release action
- name: Build the release notes
id: notes
env:
PREV_REF: ${{ steps.previous.outputs.REF }}
VERSION: ${{ steps.build_info.outputs.VERSION }}
run: |
./scripts/release_notes.sh "$PREV_REF" "$VERSION" > release_notes.md || :
cat release_notes.md
{
echo 'BODY<<__RELEASE_NOTES_EOF__'
cat release_notes.md
echo '__RELEASE_NOTES_EOF__'
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: 'automatic_releases'
uses: emsesp/action-automatic-releases@v1.0.1
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
title: Development Build v${{steps.build_info.outputs.VERSION}}
body: ${{ steps.notes.outputs.BODY }}
automatic_release_tag: 'latest'
prerelease: true
files: |
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
#
# Builds the release body for a dev build and writes it to stdout.
#
# scripts/release_notes.sh <previous release ref> <version>
#
# The summary is the set of CHANGELOG_LATEST.md lines added since the previous
# dev release, kept under their own headings. The full changelog and the commit
# list follow, both collapsed.
set -euo pipefail
PREV_REF=${1:?usage: release_notes.sh <previous release ref> <version>}
VERSION=${2:?usage: release_notes.sh <previous release ref> <version>}
CHANGELOG=CHANGELOG_LATEST.md
REPO_URL="https://github.com/${GITHUB_REPOSITORY:-emsesp/EMS-ESP32}"
MAX_COMMITS=250
prev_version=$(git show "${PREV_REF}:src/emsesp_version.h" 2>/dev/null |
awk -F'"' '/EMSESP_APP_VERSION/ { print $2 }')
added=$(mktemp)
trap 'rm -f "${added}"' EXIT
git diff -U0 "${PREV_REF}..HEAD" -- "${CHANGELOG}" |
sed -n 's/^+\([^+].*\)/\1/p' >"${added}"
# walk the changelog so the added lines keep the order and headings they have there
summary=$(awk '
NR == FNR { if (NF) wanted[$0] = 1; next }
/^#+ / { sub(/^#+ /, ""); heading = $0; next }
$0 in wanted && !seen[$0]++ {
if (heading != shown) { printf "\n### %s\n\n", heading; shown = heading }
print
}
' "${added}" "${CHANGELOG}")
echo "Development build of EMS-ESP v${VERSION}."
echo
if [ -n "${summary}" ]; then
echo "## Changes since ${prev_version:-the previous dev build}"
echo "${summary}"
echo
elif [ -n "${prev_version}" ]; then
echo "No changelog entries were added since ${prev_version}, see the commits below."
echo
fi
echo "<details>"
echo "<summary>Full v${VERSION%%-*} changelog so far</summary>"
echo
sed '1,/^For more details go to/d' "${CHANGELOG}" | awk 'NF || seen { print; seen = 1 }'
echo
echo "</details>"
echo
count=$(git rev-list --no-merges --count "${PREV_REF}..HEAD")
echo "<details>"
echo "<summary>Commits (${count})</summary>"
echo
git log --no-merges --max-count="${MAX_COMMITS}" \
--pretty=format:"- [\`%h\`](${REPO_URL}/commit/%H) %s (%an)" "${PREV_REF}..HEAD"
echo
if [ "${count}" -gt "${MAX_COMMITS}" ]; then
echo
echo "... and $((count - MAX_COMMITS)) more."
fi
echo
echo "</details>"
echo
echo "[Compare all changes](${REPO_URL}/compare/${PREV_REF}...$(git rev-parse HEAD))"