Update RPM Spec and Sync #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update RPM Spec and Sync | |
| on: | |
| workflow_run: | |
| workflows: ["Publish Python Package"] # Listens for your existing publish action | |
| types: | |
| - completed | |
| jobs: | |
| update-and-sync: | |
| runs-on: ubuntu-latest | |
| # Only run if the PyPI publish actually succeeded | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git fetch origin | |
| - name: Update RPM spec version on latest | |
| run: | | |
| git checkout latest | |
| # Extract version from your __init__.py file | |
| VERSION=$(grep -oP "^__version__ = ['\"]([^'\"]+)['\"]" src/quads_lib/__init__.py | grep -oP "[0-9]+\.[0-9]+\.[0-9]+") | |
| echo "Extracted version: $VERSION" | |
| # Update the spec file | |
| sed -i "s/^%define version.*/%define version $VERSION/" rpm/quads-lib.spec | |
| # Commit and push if there are changes | |
| git add rpm/quads-lib.spec | |
| if ! git diff --staged --quiet; then | |
| # Added [skip ci] so this commit doesn't accidentally trigger other tests | |
| git commit -m "chore: update RPM spec version to $VERSION [skip ci]" | |
| git push origin latest | |
| echo "Updated RPM spec to version $VERSION on latest" | |
| else | |
| echo "No version changes to commit" | |
| fi | |
| - name: Sync back to development | |
| run: | | |
| git checkout development | |
| # Merge the updated latest branch into development | |
| git merge origin/latest --no-edit | |
| git push origin development |