Skip to content

deprecations 202601 #133

deprecations 202601

deprecations 202601 #133

name: Auto Version Bump
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
permissions:
contents: write
pull-requests: read
issues: write
jobs:
auto-version-bump:
name: Auto Version Bump
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Import bot's GPG key for signing commits
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.PINAX_BOT_PGP_PRIVATE_KEY }}
passphrase: ${{ secrets.PINAX_BOT_PGP_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Get current version from PR branch
id: current_version
run: |
CURRENT_VERSION=$(jq -r '.version' package.json)
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
- name: Get base version from main branch
id: base_version
run: |
git fetch origin main
BASE_VERSION=$(git show origin/main:package.json | jq -r '.version')
echo "base=$BASE_VERSION" >> $GITHUB_OUTPUT
echo "Base version: $BASE_VERSION"
- name: Check if version was manually bumped
id: version_check
run: |
CURRENT="${{ steps.current_version.outputs.current }}"
BASE="${{ steps.base_version.outputs.base }}"
if [ "$CURRENT" != "$BASE" ]; then
echo "manually_bumped=true" >> $GITHUB_OUTPUT
echo "Version was manually updated from $BASE to $CURRENT"
else
echo "manually_bumped=false" >> $GITHUB_OUTPUT
echo "Version not updated - will auto-bump"
fi
- name: Determine bump type from PR labels
id: bump_type
if: steps.version_check.outputs.manually_bumped == 'false'
run: |
# Check PR labels to determine bump type
LABELS="${{ join(github.event.pull_request.labels.*.name, ' ') }}"
echo "PR labels: $LABELS"
if echo "$LABELS" | grep -q "major"; then
BUMP_TYPE="major"
elif echo "$LABELS" | grep -q "minor"; then
BUMP_TYPE="minor"
else
BUMP_TYPE="patch"
fi
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
echo "Determined bump type: $BUMP_TYPE"
- name: Auto-bump version
id: auto_bump
if: steps.version_check.outputs.manually_bumped == 'false'
run: |
chmod +x .github/scripts/bump-version.sh
./.github/scripts/bump-version.sh ${{ steps.bump_type.outputs.bump_type }}
echo "new_version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
- name: Commit version bump
if: steps.version_check.outputs.manually_bumped == 'false'
run: |
git add package.json
git commit -m "chore: auto-bump version to ${{ steps.auto_bump.outputs.new_version }} (${{ steps.bump_type.outputs.bump_type }})"
git push
env:
GITHUB_TOKEN: ${{ secrets.PINAX_BOT_GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }}
- name: Add comment to PR
if: steps.version_check.outputs.manually_bumped == 'false'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PINAX_BOT_GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "🤖 **Auto Version Bump**\n\nVersion automatically bumped from `${{ steps.current_version.outputs.current }}` to `${{ steps.auto_bump.outputs.new_version }}` (`${{ steps.bump_type.outputs.bump_type }}` bump).\n\n💡 **Tip**: Add labels `major`, `minor`, or `patch` to your PR to control the bump type. Default is `patch`."
})
- name: Skip message
if: steps.version_check.outputs.manually_bumped == 'true'
run: |
echo "✅ Version was manually updated - skipping auto-bump"