more workflow changes (#173)

Co-authored-by: Meliox <na>
This commit is contained in:
Meliox 2026-06-07 18:39:04 +02:00 committed by GitHub
parent e602663b0e
commit 335f58cd27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 15 deletions

View File

@ -1,6 +1,6 @@
name: Open / Update Version Bump PR name: Open / Update Version Bump PR
# Triggered by any push to main where src/ files changed. # Triggered by any push to main where src/, debian/ files changed.
# This happens when a feature PR is merged to main. # This happens when a feature PR is merged to main.
# Creates a dedicated chore/version-bump branch and opens a PR from it. # 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 creating a new PR it assigns the default "bump:patch" label.
@ -14,7 +14,8 @@ on:
- main - main
paths: paths:
- 'src/**' - 'src/**'
- 'debian/**'
permissions: permissions:
contents: write contents: write
pull-requests: write pull-requests: write

View File

@ -1,17 +1,16 @@
name: Version Bump name: Version Bump
# Triggered when src/ changes land on main (i.e. a PR just merged). # Triggered when the chore/version-bump PR is merged to main.
# Increments the patch version in debian/changelog and commits it. # Reads the bump:patch / bump:minor / bump:major label to determine
# The changelog commit only touches debian/changelog (not src/), # the version increment, updates debian/changelog, and commits it.
# so it does not re-trigger this workflow. # release.yml then picks up the changelog change and builds the release.
# release.yml picks up the changelog change and builds/publishes the release.
on: on:
push: pull_request:
types:
- closed
branches: branches:
- main - main
paths:
- 'src/**'
permissions: permissions:
contents: write contents: write
@ -19,8 +18,9 @@ permissions:
jobs: jobs:
bump: bump:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Skip commits made by this workflow itself if: |
if: github.actor != 'github-actions[bot]' github.event.pull_request.merged == true &&
github.event.pull_request.head.ref == 'chore/version-bump'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -28,14 +28,42 @@ jobs:
fetch-depth: 0 fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }} 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 - name: Extract and bump version
id: version id: version
env:
BUMP_TYPE: ${{ steps.bump_type.outputs.type }}
run: | run: |
CURRENT=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/') CURRENT=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
MAJOR=$(echo "$CURRENT" | cut -d. -f1) MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2) MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3) PATCH=$(echo "$CURRENT" | cut -d. -f3)
NEW="${MAJOR}.${MINOR}.$((PATCH + 1))"
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 "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "new=$NEW" >> "$GITHUB_OUTPUT" echo "new=$NEW" >> "$GITHUB_OUTPUT"
@ -48,7 +76,7 @@ jobs:
else else
LOG=$(git log --oneline -- src/ | head -50) LOG=$(git log --oneline -- src/ | head -50)
fi fi
EOF=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64) EOF=$(openssl rand -hex 16)
echo "log<<$EOF" >> "$GITHUB_OUTPUT" echo "log<<$EOF" >> "$GITHUB_OUTPUT"
echo "$LOG" >> "$GITHUB_OUTPUT" echo "$LOG" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT" echo "$EOF" >> "$GITHUB_OUTPUT"
@ -81,4 +109,4 @@ jobs:
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 commit -m "Release v${NEW_VERSION}" git commit -m "Release v${NEW_VERSION}"
git push git push