Workflow changes to fix version PR non-diff error

Co-authored-by: Meliox <na>
This commit is contained in:
Meliox 2026-06-07 19:26:33 +02:00 committed by GitHub
parent 88983fdd47
commit 9fbe8dbc15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 75 additions and 58 deletions

View File

@ -1,12 +1,10 @@
name: Open / Update Version Bump PR
# Triggered by any push to main where src/, debian/ files changed.
# This happens when a feature PR is merged to main.
# Creates a dedicated chore/version-bump branch and opens a PR from it.
# When creating a new PR it assigns the default "bump:patch" label.
# When updating an existing PR the label is NOT changed, preserving any
# manual label change (e.g. bump:minor, bump:major) made by a reviewer.
# The bot guard prevents this from firing on changelog commits.
# Triggered when any PR merges to main touching src/ or debian/.
# Accumulates changes on chore/version-bump branch by appending to CHANGES.md.
# Opens the bump PR if it doesn't exist, updates body if it does.
# Label is never changed on update — preserving manual bump:minor / bump:major.
# Bot guard prevents firing on the changelog commit from version-bump.yml.
on:
push:
@ -31,7 +29,7 @@ jobs:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Collect src/ commits from merge
- name: Collect src/ commits from this merge
id: commits
run: |
LOG=$(git log "HEAD~1..HEAD" --oneline -- src/ | head -50)
@ -40,29 +38,53 @@ jobs:
echo "$LOG" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Create or reset version bump branch
- name: Update chore/version-bump branch
env:
COMMITS: ${{ steps.commits.outputs.log }}
run: |
git checkout -B chore/version-bump
git push origin chore/version-bump --force
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Checkout existing bump branch or create it from main
git fetch origin chore/version-bump 2>/dev/null && \
git checkout chore/version-bump || \
git checkout -b chore/version-bump
# Append this merge's changes to the top of CHANGES.md
mkdir -p .github/version-bump
PREV=$(cat .github/version-bump/CHANGES.md 2>/dev/null || true)
{
echo "### Merged at $(date -R)"
echo "${COMMITS:-No src/ changes detected.}"
echo ""
echo "$PREV"
} > .github/version-bump/CHANGES.md
git add .github/version-bump/CHANGES.md
git commit -m "chore: accumulate changes from $(git rev-parse --short HEAD~1)"
git push origin chore/version-bump
- name: Build PR body from accumulated changes
run: |
VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
{
echo "## Pending changes for next release (current: v${VERSION})"
echo ""
cat .github/version-bump/CHANGES.md
echo ""
echo "---"
echo "*Change label to \`bump:minor\` or \`bump:major\` before merging if needed.*"
echo "*Default is \`bump:patch\`.*"
echo "*Merge this PR when ready to release.*"
} > /tmp/pr-body.md
- name: Create or update version bump PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMITS: ${{ steps.commits.outputs.log }}
run: |
BUMP_BRANCH="chore/version-bump"
VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
TITLE="chore: bump pve-mod to v${VERSION}"
{
echo "## Changes merged to main"
echo ""
echo "${COMMITS:-No src/ changes detected.}"
echo ""
echo "---"
echo "*Apply a bump:minor or bump:major label before merging if needed.*"
echo "*Default label is bump:patch.*"
} > /tmp/pr-body.md
TITLE="chore: release next version (current: v${VERSION})"
EXISTING=$(gh pr list \
--head "$BUMP_BRANCH" \
@ -73,7 +95,7 @@ jobs:
gh pr edit "$EXISTING" \
--title "$TITLE" \
--body-file /tmp/pr-body.md
echo "Updated PR #${EXISTING} body and title (label unchanged)"
echo "Updated PR #${EXISTING} (label unchanged)"
else
gh pr create \
--title "$TITLE" \

View File

@ -2,7 +2,7 @@ name: Build and Release
# Triggered when debian/changelog changes on main — meaning version-bump.yml
# just committed a new version. Builds the .deb and publishes a GitHub Release.
# The actor guard ensures this only fires for the bot's commit, not manual edits.
# The actor guard ensures this only fires for the bot's changelog commit.
on:
push:
@ -50,25 +50,15 @@ jobs:
dpkg-buildpackage -us -uc -b
ls -lh ../pve-mod_*.deb
- name: Collect release assets
id: assets
run: |
DEB=$(ls ../pve-mods_${{ steps.version.outputs.version }}.deb)
echo "deb=$DEB" >> "$GITHUB_OUTPUT"
- name: Extract release notes from changelog
id: notes
run: |
# Pull the top changelog entry (lines between first and second "^pve-mod (")
NOTES=$(awk '
awk '
/^pve-mod \(/ { if (found) exit; found=1; next }
found && /^ --/ { exit }
found { print }
' debian/changelog | grep '^\s*\*' | sed 's/^\s*\* /- /')
EOF=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64)
echo "notes<<$EOF" >> "$GITHUB_OUTPUT"
echo "$NOTES" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
' debian/changelog | grep '^\s*\*' | sed 's/^\s*\* /- /' > /tmp/notes.md
[[ -s /tmp/notes.md ]] || echo "- Automated release." > /tmp/notes.md
- name: Create Git tag
env:
@ -79,15 +69,22 @@ jobs:
git tag "$TAG"
git push origin "$TAG"
- name: Collect release assets
id: assets
run: |
DEB=$(ls ../pve-mod_*.deb)
echo "deb=$DEB" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
NOTES: ${{ steps.notes.outputs.notes }}
DEB: ${{ steps.assets.outputs.deb }}
run: |
ASSETS="$DEB"
[[ -f install.sh ]] && ASSETS="$ASSETS install.sh"
gh release create "$TAG" \
--title "pve-mod $TAG" \
--notes "$NOTES" \
"$DEB" \
"install.sh"
--notes-file /tmp/notes.md \
$ASSETS

View File

@ -1,9 +1,10 @@
name: Version Bump
# Triggered when the chore/version-bump PR is merged to main.
# Reads the bump:patch / bump:minor / bump:major label to determine
# the version increment, updates debian/changelog, and commits it.
# release.yml then picks up the changelog change and builds the release.
# Reads the bump:patch / bump:minor / bump:major label from the merged PR.
# Updates debian/changelog and commits to main.
# Cleans up the CHANGES.md accumulator file in the same commit.
# release.yml picks up the changelog change and builds the release.
on:
pull_request:
@ -67,15 +68,11 @@ jobs:
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "new=$NEW" >> "$GITHUB_OUTPUT"
- name: Collect src/ commits since last tag
- name: Collect accumulated changes
id: commits
run: |
LAST_TAG=$(git tag -l 'v*' | sort -V | tail -n1)
if [[ -n "$LAST_TAG" ]]; then
LOG=$(git log "${LAST_TAG}..HEAD" --oneline -- src/ | head -50)
else
LOG=$(git log --oneline -- src/ | head -50)
fi
# Read from the CHANGES.md that was merged in
LOG=$(cat .github/version-bump/CHANGES.md 2>/dev/null || true)
EOF=$(openssl rand -hex 16)
echo "log<<$EOF" >> "$GITHUB_OUTPUT"
echo "$LOG" >> "$GITHUB_OUTPUT"
@ -101,12 +98,13 @@ jobs:
} > debian/changelog.new
mv debian/changelog.new debian/changelog
- name: Commit and push changelog
- name: Commit changelog and clean up accumulator
env:
NEW_VERSION: ${{ steps.version.outputs.new }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add debian/changelog
git rm --ignore-unmatch .github/version-bump/CHANGES.md
git commit -m "Release v${NEW_VERSION}"
git push