Skip to content

Commit

Permalink
Fixing workflow bump and release to automatically open PR (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
umbertoDifa authored Mar 10, 2025
1 parent 142a314 commit 2521b39
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
bump-version:
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
TEST_VERSION="${TAG_PREFIX}${NEW_VERSION}"
echo "Adding test suffix"
# Update version in pyproject.toml and in __init__.py
awk -v new_version="$TEST_VERSION" '/^version = / {$0 = "version = \"" new_version "\""} 1' pyproject.toml > pyproject.tmp && mv pyproject.tmp pyproject.toml
awk -v new_version="$TEST_VERSION" '!changed && /^version = / {print "version = \"" new_version "\""; changed=1; next} 1' pyproject.toml > pyproject.tmp && mv pyproject.tmp pyproject.toml
awk -v new_version="$TEST_VERSION" '/^__version__ = / {$0 = "__version__ = \"" new_version "\""} 1' darwin/version/__init__.py > darwin/version/__init__.tmp && mv darwin/version/__init__.tmp darwin/version/__init__.py
BRANCH_NAME="${TAG_PREFIX}branch-${NEW_VERSION}"
Expand All @@ -109,7 +110,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create branch and commit changes
if: ${{ env.TEST_MODE == 'true' }}
run: |
echo "Creating branch ${BRANCH_NAME}"
git checkout -b ${BRANCH_NAME}
Expand All @@ -120,17 +120,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create pull request to master and auto-merge
if: ${{ env.TEST_MODE != 'true' }}
run: |
# Install GitHub CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
# Authenticate GitHub CLI
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
# Create PR
gh pr create \
--base master \
Expand All @@ -141,17 +134,8 @@ jobs:
Changes:
- Updated version in pyproject.toml
- Updated version in darwin/version/__init__.py
This PR was automatically created by the version bump workflow." \
--label "automated-pr,version-bump"
# Get PR number
PR_NUMBER=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number -q '.[0].number')
# Enable auto-merge
gh pr merge $PR_NUMBER --auto --merge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This PR was automatically created by the version bump workflow."
- name: Create and push tag
run: |
Expand Down

0 comments on commit 2521b39

Please sign in to comment.