Sync Version #5
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: Sync Version | |
| # Prevent concurrent runs to avoid push conflicts | |
| concurrency: | |
| group: sync-version-${{ github.ref }} | |
| cancel-in-progress: false | |
| on: | |
| # Run manually before releasing | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to sync (leave empty to read from pyproject.toml)' | |
| required: false | |
| type: string | |
| # Or automatically when pyproject.toml changes | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'pyproject.toml' | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Get version from pyproject.toml | |
| id: get_version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| VERSION="${{ inputs.version }}" | |
| else | |
| VERSION=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2) | |
| fi | |
| if [ -z "${VERSION}" ]; then | |
| echo "ERROR: Failed to extract version from pyproject.toml" | |
| exit 1 | |
| fi | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Syncing version: ${VERSION}" | |
| - name: Update Dockerfile | |
| run: | | |
| VERSION="${{ steps.get_version.outputs.version }}" | |
| # Update OCI image version label | |
| sed -i "s/org.opencontainers.image.version=\"[^\"]*\"/org.opencontainers.image.version=\"${VERSION}\"/" docker/Dockerfile | |
| - name: Update docker-compose.yml | |
| run: | | |
| VERSION="${{ steps.get_version.outputs.version }}" | |
| # Update version label default | |
| sed -i "s/com.mcp-jenkins.version=\${VERSION:-[^}]*}/com.mcp-jenkins.version=\${VERSION:-${VERSION}}/" docker/docker-compose.yml | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No version changes needed" | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Version changes detected:" | |
| git diff | |
| fi | |
| - name: Create pull request | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore: Sync version to ${{ steps.get_version.outputs.version }}" | |
| branch: sync-version-${{ steps.get_version.outputs.version }} | |
| title: "chore: Sync version to ${{ steps.get_version.outputs.version }}" | |
| body: | | |
| Automated version sync to ${{ steps.get_version.outputs.version }}. |