chore: format & lint #141
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: | |
| push: | |
| branches: | |
| - main | |
| - staging | |
| # - development # No need to bump version for development branch because we don't build the extension for development branch | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整历史 | |
| - name: Find nearest version tag | |
| id: get_tag | |
| run: | | |
| tag=$(git describe --tags --match "v*" --abbrev=0) | |
| echo "Found tag: $tag" | |
| echo "tag=$tag" >> $GITHUB_OUTPUT | |
| - name: Bump version | |
| id: bump | |
| run: | | |
| tag="${{ steps.get_tag.outputs.tag }}" | |
| branch="${{ github.ref_name }}" | |
| # Remove v prefix | |
| version="${tag#v}" | |
| # Parse version parts | |
| IFS='.' read -r -a parts <<< "$version" | |
| if [ "$branch" = "staging" ]; then | |
| # Staging branch: bump patch version (last value) | |
| # v2.1.2 --> v2.1.3 | |
| last_index=$((${#parts[@]} - 1)) | |
| parts[$last_index]=$((parts[$last_index] + 1)) | |
| elif [ "$branch" = "main" ]; then | |
| # Main branch: bump minor version and set patch to 0 | |
| # v2.1.2 --> v2.2.0 | |
| if [ ${#parts[@]} -ge 2 ]; then | |
| parts[1]=$((parts[1] + 1)) | |
| # Set patch version to 0 | |
| if [ ${#parts[@]} -ge 3 ]; then | |
| parts[2]=0 | |
| fi | |
| fi | |
| fi | |
| # Reassemble | |
| new_version="${parts[0]}" | |
| for i in $(seq 1 $((${#parts[@]} - 1))); do | |
| new_version="${new_version}.${parts[$i]}" | |
| done | |
| new_tag="v${new_version}" | |
| echo "Branch: $branch" | |
| echo "Bumped tag: $new_tag" | |
| echo "new_tag=$new_tag" >> $GITHUB_OUTPUT | |
| - name: Create and push new tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "${{ steps.bump.outputs.new_tag }}" | |
| git push origin "${{ steps.bump.outputs.new_tag }}" | |
| - name: Repository Dispatch (main -> prd) | |
| if: github.ref_name == 'main' | |
| uses: peter-evans/repository-dispatch@v4 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| repository: PaperDebugger/paperdebugger | |
| event-type: prd | |
| client-payload: '{"tag": "${{ steps.bump.outputs.new_tag }}", "branch": "${{ github.ref_name }}"}' | |
| - name: Repository Dispatch (staging -> stg) | |
| if: github.ref_name == 'staging' | |
| uses: peter-evans/repository-dispatch@v4 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| repository: PaperDebugger/paperdebugger | |
| event-type: stg | |
| client-payload: '{"tag": "${{ steps.bump.outputs.new_tag }}", "branch": "${{ github.ref_name }}"}' |