39 lines
1.1 KiB
YAML
39 lines
1.1 KiB
YAML
name: Sync pyproject.toml Version
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["Publish Python Package"]
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
commit-version-update:
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "CI Bot"
|
|
git config user.email "ci-bot@example.com"
|
|
|
|
- name: Update version in pyproject.toml to match tag
|
|
run: |
|
|
TAG_VERSION="${{ github.event.workflow_run.head_branch }}"
|
|
VERSION="${TAG_VERSION#v}"
|
|
sed -i.bak -E "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
|
|
rm pyproject.toml.bak
|
|
|
|
- name: Commit and push changes
|
|
run: |
|
|
git add pyproject.toml
|
|
git commit -m "chore: update version in pyproject.toml to ${VERSION} [skip ci]" || echo "No changes to commit"
|
|
git push
|