109 lines
3.8 KiB
YAML
109 lines
3.8 KiB
YAML
name: Version Bump
|
|
|
|
# Triggered when the chore/version-bump PR is merged to main.
|
|
# 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:
|
|
types:
|
|
- closed
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
bump:
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
github.event.pull_request.merged == true &&
|
|
github.event.pull_request.head.ref == 'chore/version-bump'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Determine bump type from PR label
|
|
id: bump_type
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '[.labels[].name] | join(",")')
|
|
echo "Labels found: $LABELS"
|
|
|
|
if echo "$LABELS" | grep -q 'bump:major'; then
|
|
echo "type=major" >> "$GITHUB_OUTPUT"
|
|
elif echo "$LABELS" | grep -q 'bump:minor'; then
|
|
echo "type=minor" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "type=patch" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Extract and bump version
|
|
id: version
|
|
env:
|
|
BUMP_TYPE: ${{ steps.bump_type.outputs.type }}
|
|
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)
|
|
|
|
if [[ "$BUMP_TYPE" == "major" ]]; then
|
|
NEW="$((MAJOR + 1)).0.0"
|
|
elif [[ "$BUMP_TYPE" == "minor" ]]; then
|
|
NEW="${MAJOR}.$((MINOR + 1)).0"
|
|
else
|
|
NEW="${MAJOR}.${MINOR}.$((PATCH + 1))"
|
|
fi
|
|
|
|
echo "Bumping $CURRENT → $NEW ($BUMP_TYPE)"
|
|
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
|
|
echo "new=$NEW" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Collect accumulated changes
|
|
id: commits
|
|
run: |
|
|
# 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"
|
|
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 and clean up accumulator
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git checkout -b release/v${{ steps.version.outputs.new }}
|
|
git add debian/changelog
|
|
git rm --ignore-unmatch .github/version-bump/CHANGES.md
|
|
git commit -m "Release v${{ steps.version.outputs.new }}"
|
|
git push -u origin release/v${{ steps.version.outputs.new }} |