PVE-mods/.github/workflows/version-bump.yml
Workflow config file is invalid. Please check your config file: yaml: line 98: could not find expected ':'
2026-06-07 12:55:03 +02:00

118 lines
3.8 KiB
YAML

name: Version Bump
# Triggered by any push to src/ on non-main branches.
# Increments the patch version in debian/changelog, commits it,
# and opens (or updates) a "Release vX.Y.Z" PR to main.
# The changelog commit touches only debian/changelog (not src/),
# so it does not re-trigger this workflow.
on:
push:
branches-ignore:
- main
paths:
- 'src/**'
permissions:
contents: write
pull-requests: write
jobs:
bump:
runs-on: ubuntu-latest
# Skip commits made by this workflow itself
if: github.actor != 'github-actions[bot]'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract and bump version
id: version
run: |
CURRENT=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
NEW="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "new=$NEW" >> "$GITHUB_OUTPUT"
- name: Build PR body from src/ commits since last release
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
# Escape for GitHub multiline output
EOF=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64)
echo "log<<$EOF" >> "$GITHUB_OUTPUT"
echo "$LOG" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Prepend new changelog entry
env:
NEW_VERSION: ${{ steps.version.outputs.new }}
COMMITS: ${{ steps.commits.outputs.log }}
run: |
DATE=$(date -R)
{
echo "pve-mod ($NEW_VERSION) stable; urgency=low"
echo ""
while IFS= read -r line; do
[[ -n "$line" ]] && echo " * $line"
done <<< "$COMMITS"
[[ -z "$COMMITS" ]] && echo " * Automated version bump."
echo ""
echo " -- github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> $DATE"
echo ""
cat debian/changelog
} > debian/changelog.new
mv debian/changelog.new debian/changelog
- name: Commit changelog
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 commit -m "Release v${NEW_VERSION}"
git push
- name: Create or update release PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ steps.version.outputs.new }}
COMMITS: ${{ steps.commits.outputs.log }}
BRANCH: ${{ github.ref_name }}
run: |
TITLE="Release v${NEW_VERSION}"
BODY="## Changes since last release
${COMMITS:-No src/ changes detected.}
---
*Merge this PR to build and publish the \`pve-mod_${NEW_VERSION}_all.deb\` release.*"
# Check if a PR for this version already exists
EXISTING=$(gh pr list \
--search "\"$TITLE\" in:title" \
--json number --jq '.[0].number' 2>/dev/null || true)
if [[ -n "$EXISTING" ]]; then
gh pr edit "$EXISTING" --body "$BODY"
echo "Updated existing PR #$EXISTING"
else
gh pr create \
--title "$TITLE" \
--body "$BODY" \
--base main \
--head "$BRANCH"
fi