auto version bump after github release (#1988)

This commit is contained in:
Shuchang Zheng
2025-03-24 09:18:03 -07:00
committed by GitHub
parent b1e6c7daf7
commit a98e7781c0
2 changed files with 77 additions and 3 deletions

View File

@@ -2,16 +2,49 @@ name: Build Skyvern SDK and publish to PyPI
on:
workflow_dispatch:
release:
types: [ published ]
push:
branches:
- main
paths:
- 'pyproject.toml'
jobs:
check-version-change:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.check.outputs.version_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if version changed
id: check
run: |
# Get version from current pyproject.toml
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
# Get version from previous commit
git checkout HEAD^1
PREVIOUS_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "Version remained at $CURRENT_VERSION"
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
run-ci:
needs: check-version-change
if: needs.check-version-change.outputs.version_changed == 'true'
uses: ./.github/workflows/ci.yml
build-sdk:
runs-on: ubuntu-latest
needs: [ run-ci ]
needs: [check-version-change, run-ci]
if: needs.check-version-change.outputs.version_changed == 'true'
steps:
- name: Check out Git repository
uses: actions/checkout@v4

41
.github/workflows/version-bump.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Version Bump on Release
on:
release:
types: [published]
jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Extract version from release
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \".*\"/version = \"${{ steps.get_version.outputs.version }}\"/" pyproject.toml
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore: bump version to ${{ steps.get_version.outputs.version }}"
title: "chore: bump version to ${{ steps.get_version.outputs.version }}"
body: "Auto-generated PR to update version in pyproject.toml"
branch: "version-bump/${{ steps.get_version.outputs.version }}"
delete-branch: true
- name: Enable Pull Request Automerge
if: steps.create-pr.outputs.pull-request-number
run: |
gh pr merge --auto --merge "${{ steps.create-pr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}