Release-0.1.0 #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: Create Release Tag | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| create-tag: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.13 | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e external/devops | |
| - name: Extract release version (Release-x.y.z OR hotfix bump) | |
| id: extract_version | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| title="${{ github.event.pull_request.title }}" | |
| body="${{ github.event.pull_request.body }}" | |
| head_ref="${{ github.head_ref }}" # PR source branch name, e.g. hotfix/... | |
| echo "PR source branch: $head_ref" | |
| echo "PR title: $title" | |
| # Hotfix: version = latest tag + 1 in patch | |
| if [[ "$head_ref" == hotfix/* ]]; then | |
| echo "✅ Hotfix PR detected. Deducing version from latest tag + patch bump..." | |
| git fetch --tags --force | |
| version="$(increase_latest_tag --patch)" | |
| echo "✅ Hotfix release version: $version" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| # Non-hotfix: expect Release-x.y.z in title/body | |
| regex='[Rr][Ee][Ll][Ee][Aa][Ss][Ee]-([0-9]+\.[0-9]+\.[0-9]+)' | |
| if [[ "$title" =~ $regex ]]; then | |
| version="${BASH_REMATCH[1]}" | |
| elif [[ "$body" =~ $regex ]]; then | |
| version="${BASH_REMATCH[1]}" | |
| else | |
| echo "❌ No valid release version found in PR title or description." | |
| echo " Expected: Release-x.y.z (e.g., Release-1.2.3)" | |
| echo " Or use a hotfix/* branch to auto-bump patch." | |
| exit 1 | |
| fi | |
| echo "✅ Found release version: $version" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Update CHANGELOG.md | |
| run: | | |
| version="${{ steps.extract_version.outputs.version }}" | |
| update_changelog "$version" | |
| - name: Commit and push changelog update | |
| run: | | |
| version="${{ steps.extract_version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add CHANGELOG.md | |
| git commit -m "docs: update changelog for $version" || echo "No changes to commit" | |
| git push origin HEAD:main | |
| - name: Create Git tag | |
| run: | | |
| version="${{ steps.extract_version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Safety: don't fail if tag already exists (e.g., re-runs) | |
| if git rev-parse -q --verify "refs/tags/$version" >/dev/null; then | |
| echo "Tag $version already exists. Skipping tag creation." | |
| exit 0 | |
| fi | |
| git tag "$version" | |
| git push origin "$version" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.extract_version.outputs.version }} | |
| name: Release ${{ steps.extract_version.outputs.version }} | |
| body: | | |
| 🚀 **Automatic release:** `${{ steps.extract_version.outputs.version }}` | |
| - Created from PR: #${{ github.event.pull_request.number }} | |
| - Commit: `${{ github.sha }}` | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Merge main back into dev | |
| run: | | |
| git fetch origin dev | |
| git checkout dev | |
| git merge origin/main --no-edit | |
| git push origin dev |