name: Version bump on: push: branches: [development, main] permissions: contents: write jobs: bump: # Never trigger on our own bump commits. if: >- github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip ci]') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Configure git identity run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - name: Bump version id: bump run: | set -euo pipefail read -r major minor patch < <(tr '.' ' ' < VERSION) if [ "${GITHUB_REF_NAME}" = "development" ]; then patch=$((patch + 1)) else # main: a merge commit that brings in development's tip is the # approved development -> main promotion (MINOR bump); anything # else pushed directly to main is a hotfix (PATCH bump). if git log -1 --pretty=%P | grep -qE '.+ .+' && \ git merge-base --is-ancestor HEAD^2 origin/development 2>/dev/null; then minor=$((minor + 1)) patch=0 else patch=$((patch + 1)) fi fi new_version="${major}.${minor}.${patch}" echo "$new_version" > VERSION echo "new_version=$new_version" >> "$GITHUB_OUTPUT" - name: Commit and push version bump run: | git add VERSION git commit -m "chore(release): v${{ steps.bump.outputs.new_version }} [skip ci]" git push origin "HEAD:${GITHUB_REF_NAME}" - name: Merge main back into development if: github.ref_name == 'main' run: | git fetch origin development git checkout development git merge --no-edit origin/main git push origin development