Workflow changes to fix version PR non-diff error
Co-authored-by: Meliox <na>
This commit is contained in:
parent
88983fdd47
commit
9fbe8dbc15
72
.github/workflows/pr-create.yml
vendored
72
.github/workflows/pr-create.yml
vendored
@ -1,12 +1,10 @@
|
|||||||
name: Open / Update Version Bump PR
|
name: Open / Update Version Bump PR
|
||||||
|
|
||||||
# Triggered by any push to main where src/, debian/ files changed.
|
# Triggered when any PR merges to main touching src/ or debian/.
|
||||||
# This happens when a feature PR is merged to main.
|
# Accumulates changes on chore/version-bump branch by appending to CHANGES.md.
|
||||||
# Creates a dedicated chore/version-bump branch and opens a PR from it.
|
# Opens the bump PR if it doesn't exist, updates body if it does.
|
||||||
# When creating a new PR it assigns the default "bump:patch" label.
|
# Label is never changed on update — preserving manual bump:minor / bump:major.
|
||||||
# When updating an existing PR the label is NOT changed, preserving any
|
# Bot guard prevents firing on the changelog commit from version-bump.yml.
|
||||||
# manual label change (e.g. bump:minor, bump:major) made by a reviewer.
|
|
||||||
# The bot guard prevents this from firing on changelog commits.
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -15,7 +13,7 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- 'src/**'
|
- 'src/**'
|
||||||
- 'debian/**'
|
- 'debian/**'
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
@ -31,7 +29,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Collect src/ commits from merge
|
- name: Collect src/ commits from this merge
|
||||||
id: commits
|
id: commits
|
||||||
run: |
|
run: |
|
||||||
LOG=$(git log "HEAD~1..HEAD" --oneline -- src/ | head -50)
|
LOG=$(git log "HEAD~1..HEAD" --oneline -- src/ | head -50)
|
||||||
@ -40,29 +38,53 @@ jobs:
|
|||||||
echo "$LOG" >> "$GITHUB_OUTPUT"
|
echo "$LOG" >> "$GITHUB_OUTPUT"
|
||||||
echo "$EOF" >> "$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: |
|
run: |
|
||||||
git checkout -B chore/version-bump
|
git config user.name "github-actions[bot]"
|
||||||
git push origin chore/version-bump --force
|
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
|
- name: Create or update version bump PR
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
COMMITS: ${{ steps.commits.outputs.log }}
|
|
||||||
run: |
|
run: |
|
||||||
BUMP_BRANCH="chore/version-bump"
|
BUMP_BRANCH="chore/version-bump"
|
||||||
VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
|
VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
|
||||||
TITLE="chore: bump pve-mod to v${VERSION}"
|
TITLE="chore: release next version (current: 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
|
|
||||||
|
|
||||||
EXISTING=$(gh pr list \
|
EXISTING=$(gh pr list \
|
||||||
--head "$BUMP_BRANCH" \
|
--head "$BUMP_BRANCH" \
|
||||||
@ -73,7 +95,7 @@ jobs:
|
|||||||
gh pr edit "$EXISTING" \
|
gh pr edit "$EXISTING" \
|
||||||
--title "$TITLE" \
|
--title "$TITLE" \
|
||||||
--body-file /tmp/pr-body.md
|
--body-file /tmp/pr-body.md
|
||||||
echo "Updated PR #${EXISTING} body and title (label unchanged)"
|
echo "Updated PR #${EXISTING} (label unchanged)"
|
||||||
else
|
else
|
||||||
gh pr create \
|
gh pr create \
|
||||||
--title "$TITLE" \
|
--title "$TITLE" \
|
||||||
|
|||||||
37
.github/workflows/release.yml
vendored
37
.github/workflows/release.yml
vendored
@ -2,7 +2,7 @@ name: Build and Release
|
|||||||
|
|
||||||
# Triggered when debian/changelog changes on main — meaning version-bump.yml
|
# Triggered when debian/changelog changes on main — meaning version-bump.yml
|
||||||
# just committed a new version. Builds the .deb and publishes a GitHub Release.
|
# 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:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -50,25 +50,15 @@ jobs:
|
|||||||
dpkg-buildpackage -us -uc -b
|
dpkg-buildpackage -us -uc -b
|
||||||
ls -lh ../pve-mod_*.deb
|
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
|
- name: Extract release notes from changelog
|
||||||
id: notes
|
id: notes
|
||||||
run: |
|
run: |
|
||||||
# Pull the top changelog entry (lines between first and second "^pve-mod (")
|
awk '
|
||||||
NOTES=$(awk '
|
|
||||||
/^pve-mod \(/ { if (found) exit; found=1; next }
|
/^pve-mod \(/ { if (found) exit; found=1; next }
|
||||||
found && /^ --/ { exit }
|
found && /^ --/ { exit }
|
||||||
found { print }
|
found { print }
|
||||||
' debian/changelog | grep '^\s*\*' | sed 's/^\s*\* /- /')
|
' debian/changelog | grep '^\s*\*' | sed 's/^\s*\* /- /' > /tmp/notes.md
|
||||||
EOF=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64)
|
[[ -s /tmp/notes.md ]] || echo "- Automated release." > /tmp/notes.md
|
||||||
echo "notes<<$EOF" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "$NOTES" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "$EOF" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Create Git tag
|
- name: Create Git tag
|
||||||
env:
|
env:
|
||||||
@ -79,15 +69,22 @@ jobs:
|
|||||||
git tag "$TAG"
|
git tag "$TAG"
|
||||||
git push origin "$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
|
- name: Create GitHub Release
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
TAG: ${{ steps.version.outputs.tag }}
|
||||||
NOTES: ${{ steps.notes.outputs.notes }}
|
DEB: ${{ steps.assets.outputs.deb }}
|
||||||
DEB: ${{ steps.assets.outputs.deb }}
|
|
||||||
run: |
|
run: |
|
||||||
|
ASSETS="$DEB"
|
||||||
|
[[ -f install.sh ]] && ASSETS="$ASSETS install.sh"
|
||||||
|
|
||||||
gh release create "$TAG" \
|
gh release create "$TAG" \
|
||||||
--title "pve-mod $TAG" \
|
--title "pve-mod $TAG" \
|
||||||
--notes "$NOTES" \
|
--notes-file /tmp/notes.md \
|
||||||
"$DEB" \
|
$ASSETS
|
||||||
"install.sh"
|
|
||||||
24
.github/workflows/version-bump.yml
vendored
24
.github/workflows/version-bump.yml
vendored
@ -1,9 +1,10 @@
|
|||||||
name: Version Bump
|
name: Version Bump
|
||||||
|
|
||||||
# Triggered when the chore/version-bump PR is merged to main.
|
# Triggered when the chore/version-bump PR is merged to main.
|
||||||
# Reads the bump:patch / bump:minor / bump:major label to determine
|
# Reads the bump:patch / bump:minor / bump:major label from the merged PR.
|
||||||
# the version increment, updates debian/changelog, and commits it.
|
# Updates debian/changelog and commits to main.
|
||||||
# release.yml then picks up the changelog change and builds the release.
|
# Cleans up the CHANGES.md accumulator file in the same commit.
|
||||||
|
# release.yml picks up the changelog change and builds the release.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@ -31,7 +32,7 @@ jobs:
|
|||||||
- name: Determine bump type from PR label
|
- name: Determine bump type from PR label
|
||||||
id: bump_type
|
id: bump_type
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
run: |
|
run: |
|
||||||
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '[.labels[].name] | join(",")')
|
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '[.labels[].name] | join(",")')
|
||||||
@ -67,15 +68,11 @@ jobs:
|
|||||||
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
|
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
|
||||||
echo "new=$NEW" >> "$GITHUB_OUTPUT"
|
echo "new=$NEW" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Collect src/ commits since last tag
|
- name: Collect accumulated changes
|
||||||
id: commits
|
id: commits
|
||||||
run: |
|
run: |
|
||||||
LAST_TAG=$(git tag -l 'v*' | sort -V | tail -n1)
|
# Read from the CHANGES.md that was merged in
|
||||||
if [[ -n "$LAST_TAG" ]]; then
|
LOG=$(cat .github/version-bump/CHANGES.md 2>/dev/null || true)
|
||||||
LOG=$(git log "${LAST_TAG}..HEAD" --oneline -- src/ | head -50)
|
|
||||||
else
|
|
||||||
LOG=$(git log --oneline -- src/ | head -50)
|
|
||||||
fi
|
|
||||||
EOF=$(openssl rand -hex 16)
|
EOF=$(openssl rand -hex 16)
|
||||||
echo "log<<$EOF" >> "$GITHUB_OUTPUT"
|
echo "log<<$EOF" >> "$GITHUB_OUTPUT"
|
||||||
echo "$LOG" >> "$GITHUB_OUTPUT"
|
echo "$LOG" >> "$GITHUB_OUTPUT"
|
||||||
@ -84,7 +81,7 @@ jobs:
|
|||||||
- name: Prepend new changelog entry
|
- name: Prepend new changelog entry
|
||||||
env:
|
env:
|
||||||
NEW_VERSION: ${{ steps.version.outputs.new }}
|
NEW_VERSION: ${{ steps.version.outputs.new }}
|
||||||
COMMITS: ${{ steps.commits.outputs.log }}
|
COMMITS: ${{ steps.commits.outputs.log }}
|
||||||
run: |
|
run: |
|
||||||
DATE=$(date -R)
|
DATE=$(date -R)
|
||||||
{
|
{
|
||||||
@ -101,12 +98,13 @@ jobs:
|
|||||||
} > debian/changelog.new
|
} > debian/changelog.new
|
||||||
mv debian/changelog.new debian/changelog
|
mv debian/changelog.new debian/changelog
|
||||||
|
|
||||||
- name: Commit and push changelog
|
- name: Commit changelog and clean up accumulator
|
||||||
env:
|
env:
|
||||||
NEW_VERSION: ${{ steps.version.outputs.new }}
|
NEW_VERSION: ${{ steps.version.outputs.new }}
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
git add debian/changelog
|
git add debian/changelog
|
||||||
|
git rm --ignore-unmatch .github/version-bump/CHANGES.md
|
||||||
git commit -m "Release v${NEW_VERSION}"
|
git commit -m "Release v${NEW_VERSION}"
|
||||||
git push
|
git push
|
||||||
Loading…
Reference in New Issue
Block a user