Debian Codegraph @

.github/workflows/tag-release.yml

raw symbols SCIP
1 name: Tag Release
2
3 on:
4 push:
5 branches: [main]
6
7 env:
8 CARGO_TERM_COLOR: always
9
10 jobs:
11 tag-release:
12 name: Tag release and bump dev version
13 runs-on: ubuntu-latest
14 permissions:
15 contents: write
16 pull-requests: write
17 # Only run if the commit message starts with "release: v" (matches merge commit titles)
18 if: "startsWith(github.event.head_commit.message, 'release: v')"
19
20 steps:
21 - uses: actions/checkout@v4
22 with:
23 fetch-depth: 0
24 token: ${{ secrets.RELEASE_TOKEN }}
25
26 - name: Configure git
27 run: |
28 git config user.name "github-actions[bot]"
29 git config user.email "github-actions[bot]@users.noreply.github.com"
30
31 - name: Extract version
32 id: version
33 run: |
34 VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
35 echo "version=$VERSION" >> $GITHUB_OUTPUT
36 echo "Detected version: $VERSION"
37
38 - name: Check if tag exists
39 id: check_tag
40 run: |
41 if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
42 echo "exists=true" >> $GITHUB_OUTPUT
43 echo "Tag v${{ steps.version.outputs.version }} already exists"
44 else
45 echo "exists=false" >> $GITHUB_OUTPUT
46 fi
47
48 - name: Create and push tag
49 if: steps.check_tag.outputs.exists == 'false'
50 run: |
51 git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
52 git push origin "v${{ steps.version.outputs.version }}"
53 echo "Created and pushed tag v${{ steps.version.outputs.version }}"
54
55 - name: Bump to next dev version
56 if: steps.check_tag.outputs.exists == 'false'
57 env:
58 GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
59 run: |
60 # Calculate next dev version (patch bump + alpha.0)
61 VERSION="${{ steps.version.outputs.version }}"
62 IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
63 NEXT_DEV="${MAJOR}.${MINOR}.$((PATCH + 1))-alpha.0"
64 echo "Bumping to next dev version: $NEXT_DEV"
65
66 # Create branch, update version, and open PR
67 BRANCH="chore/bump-${NEXT_DEV}"
68 git checkout -b "$BRANCH"
69
70 sed -i "0,/^version = \"${VERSION}\"/s//version = \"${NEXT_DEV}\"/" Cargo.toml
71
72 git add Cargo.toml
73 git commit -m "chore: bump to ${NEXT_DEV} for next development iteration"
74 git push origin "$BRANCH"
75
76 gh pr create \
77 --title "chore: bump to ${NEXT_DEV} for next development iteration" \
78 --body "Automated version bump after v${VERSION} release." \
79 --head "$BRANCH" \
80 --base main
81
82 - name: Summary
83 run: |
84 echo "## Release Tagged" >> $GITHUB_STEP_SUMMARY
85 echo "" >> $GITHUB_STEP_SUMMARY
86 if [ "${{ steps.check_tag.outputs.exists }}" == "true" ]; then
87 echo "Tag v${{ steps.version.outputs.version }} already existed, skipped." >> $GITHUB_STEP_SUMMARY
88 else
89 echo "- Created tag: v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
90 echo "- Bumped to next dev version" >> $GITHUB_STEP_SUMMARY
91 echo "" >> $GITHUB_STEP_SUMMARY
92 echo "The release workflow will now build and publish artifacts." >> $GITHUB_STEP_SUMMARY
93 fi