Fixes from 14 Jan Real Testing #43
Workflow file for this run
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: Bump Version | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.RELEASE_MANAGER_APPID }} | |
| private-key: ${{ secrets.RELEASE_MANAGER_SECRET }} | |
| owner: First-Order-RoboCup-SSL | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Set up Pixi | |
| uses: prefix-dev/setup-pixi@v0.8.0 | |
| with: | |
| cache: true | |
| - name: Configure Git User | |
| run: | | |
| git config user.name "utama-release-manager[bot]" | |
| git config user.email "232491996+utama-release-manager[bot]@users.noreply.github.com" | |
| - name: Install toml-cli | |
| run: pip install toml-cli==0.8.2 jq==1.10.0 | |
| - name: Fetch main version | |
| id: main_version | |
| run: | | |
| git fetch origin main | |
| MAIN_VERSION=$(git show origin/main:utama_core/__init__.py | grep '__version__' | cut -d '"' -f 2) | |
| echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV | |
| echo "Main branch version: $MAIN_VERSION" | |
| - name: Determine bump type from PR labels | |
| id: bump_type | |
| run: | | |
| BUMP="patch" # default | |
| for label in $(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH"); do | |
| case "$label" in | |
| "release:major") BUMP="major" ;; | |
| "release:minor") BUMP="minor" ;; | |
| "release:patch") BUMP="patch" ;; | |
| esac | |
| done | |
| echo "Determined bump type: $BUMP" | |
| echo "BUMP_TYPE=$BUMP" >> $GITHUB_OUTPUT | |
| - name: Bump version | |
| id: bump_version | |
| run: | | |
| # Get PR branch version | |
| PR_VERSION=$(grep '__version__' utama_core/__init__.py | cut -d '"' -f 2) | |
| echo "PR branch version: $PR_VERSION" | |
| # Convert to arrays | |
| echo "Bumping version (${{ steps.bump_type.outputs.BUMP_TYPE }})..." | |
| pixi run hatch version ${{ steps.bump_type.outputs.BUMP_TYPE }} | |
| # Update pixi.toml | |
| NEW_VERSION=$(grep '__version__' utama_core/__init__.py | cut -d '"' -f 2) | |
| toml set --toml-path pixi.toml workspace.version "$NEW_VERSION" | |
| toml set --toml-path pixi.toml package.version "$NEW_VERSION" | |
| # Commit and push to PR branch | |
| git add pyproject.toml pixi.toml utama_core/__init__.py | |
| git commit -m "chore(release): bump version to v$NEW_VERSION" | |
| git remote set-url origin https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ github.repository }} | |
| git push origin HEAD:main | |
| echo "Version bumped to $NEW_VERSION" | |
| # Set output for next step | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Tag release at PR merge commit | |
| run: | | |
| # Get the PR merge commit SHA | |
| MERGE_COMMIT_SHA=$(jq -r .pull_request.merge_commit_sha "$GITHUB_EVENT_PATH") | |
| echo "Tagging PR merge commit $MERGE_COMMIT_SHA with v${{ steps.bump_version.outputs.new_version }}" | |
| git tag -a "v${{ steps.bump_version.outputs.new_version }}" -m "Release v${{ steps.bump_version.outputs.new_version }}" $MERGE_COMMIT_SHA | |
| git push origin "v${{ steps.bump_version.outputs.new_version }}" | |
| - name: Bump dependent repositories | |
| if: success() && steps.bump_version.outputs.new_version != '' | |
| run: | | |
| NEW_VERSION=${{ steps.bump_version.outputs.new_version }} | |
| for REPO in $DEPENDENT_REPOS; do | |
| echo "Updating dependency in $REPO..." | |
| git clone "https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/$REPO.git" | |
| cd "$(basename "$REPO")" | |
| # Example: update version reference inside pyproject.toml or pixi.toml | |
| # Adjust search/replace as needed for your dependency structure | |
| if grep -q 'utama_core' pixi.toml; then | |
| toml set --toml-path pixi.toml pypi-dependencies."utama-core".rev "v${NEW_VERSION}" | |
| pixi update | |
| fi | |
| git config user.name "utama-release-manager[bot]" | |
| git config user.email "232491996+utama-release-manager[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "chore(deps): bump utama_core to v${NEW_VERSION}" || echo "No changes to commit" | |
| git push origin main || echo "No push needed" | |
| cd .. | |
| rm -rf "$(basename "$REPO")" | |
| done | |
| echo "Dependent repositories updated." | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2.3.3 | |
| with: | |
| tag_name: "v${{ steps.bump_version.outputs.new_version }}" | |
| body: "Automated release generated from PR #${{ github.event.pull_request.number }}" | |
| draft: false | |
| prerelease: false | |
| env: | |
| DEPENDENT_REPOS: | | |
| First-Order-RoboCup-SSL/Utama-Strategy |