ci(release): add workflow to auto-publish GitHub Release on version.js change

This commit is contained in:
Ryan
2025-10-25 20:54:49 -04:00
committed by GitHub
parent badcf5c02b
commit 2ba33f40f8

View File

@@ -3,9 +3,10 @@ name: Release on version.js update
on: on:
push: push:
branches: [ master ] branches:
- master
paths: paths:
- 'public/js/version.js' - public/js/version.js
permissions: permissions:
contents: write contents: write
@@ -28,12 +29,10 @@ jobs:
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
if [[ ! -f public/js/version.js ]]; then VER=$(grep -Eo "APP_VERSION\s*=\s*['\"]v[^'\"]+['\"]" public/js/version.js | sed -E "s/.*['\"](v[^'\"]+)['\"].*/\1/")
echo "version.js not found"; exit 1
fi
VER=$(grep -Eo "APP_VERSION\s*=\s*'v[^']+'" public/js/version.js | sed -E "s/.*'([^']+)'.*/\1/")
if [[ -z "$VER" ]]; then if [[ -z "$VER" ]]; then
echo "Could not parse APP_VERSION from version.js"; exit 1 echo "Could not parse APP_VERSION from version.js" >&2
exit 1
fi fi
echo "version=$VER" >> "$GITHUB_OUTPUT" echo "version=$VER" >> "$GITHUB_OUTPUT"
echo "Parsed version: $VER" echo "Parsed version: $VER"
@@ -59,7 +58,6 @@ jobs:
set -euo pipefail set -euo pipefail
NOTES_PATH="" NOTES_PATH=""
if [[ -f CHANGELOG.md ]]; then if [[ -f CHANGELOG.md ]]; then
# Extract from first "## " until a line that is exactly "---"
awk ' awk '
BEGIN{found=0} BEGIN{found=0}
/^## / && !found {found=1} /^## / && !found {found=1}
@@ -67,21 +65,14 @@ jobs:
found {print} found {print}
' CHANGELOG.md > RELEASE_BODY.md || true ' CHANGELOG.md > RELEASE_BODY.md || true
# Clean up trailing blank lines # Trim trailing blank lines
sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' RELEASE_BODY.md || true sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' RELEASE_BODY.md || true
if [[ -s RELEASE_BODY.md ]]; then if [[ -s RELEASE_BODY.md ]]; then
NOTES_PATH="RELEASE_BODY.md" NOTES_PATH="RELEASE_BODY.md"
echo "Using extracted notes:"
head -n 60 RELEASE_BODY.md
else
echo "Top section not found or empty; will use auto-generated notes."
fi fi
else
echo "No CHANGELOG.md; will use auto-generated notes."
fi fi
echo "path=$NOTES_PATH" >> "$GITHUB_OUTPUT"
echo "path=${NOTES_PATH}" >> "$GITHUB_OUTPUT"
- name: (optional) Build archive to attach - name: (optional) Build archive to attach
if: steps.tagcheck.outputs.exists == 'false' if: steps.tagcheck.outputs.exists == 'false'
@@ -89,7 +80,6 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
zip -r "FileRise-${{ steps.ver.outputs.version }}.zip" public/ README.md LICENSE >/dev/null || true zip -r "FileRise-${{ steps.ver.outputs.version }}.zip" public/ README.md LICENSE >/dev/null || true
ls -l "FileRise-${{ steps.ver.outputs.version }}.zip" || true
# Path A: we have extracted notes -> use body_path # Path A: we have extracted notes -> use body_path
- name: Create GitHub Release (with CHANGELOG snippet) - name: Create GitHub Release (with CHANGELOG snippet)