File size: 2,555 Bytes
a92550e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca425f9
a92550e
280c7e2
a92550e
 
5726782
a92550e
280c7e2
a92550e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280c7e2
a92550e
 
 
 
 
 
 
 
 
280c7e2
a92550e
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Bump release version
on:
  pull_request:
    branches: [rolling]
    types:
      - closed

permissions:
  contents: write
  pull-requests: write
  repository-projects: write

concurrency: production

jobs:
  build:
    name: bump tag version and release  
    if: github.event.pull_request.merged == true 
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ github.sha }}
          fetch-depth: 0
      - name: Bump version and push tag
        id: version-bump
        uses: hennejg/[email protected]
        with:
          github_token: ${{ secrets.ADMIN_RIGHTS_TOKEN }}
          release_branches: rolling
      - name: create branch 
        uses: peterjgrainger/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.ADMIN_RIGHTS_TOKEN }}
        with:
          branch: update-from-${{ github.sha }}
      - name: update cargo.toml
        run: |
          appversion=$(echo "${{ steps.version-bump.outputs.new_tag }}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
          sed -i -e "s/^version = .*/version = \"$appversion\"/" Cargo.toml
      - run: rustup toolchain install stable --profile minimal
      - run: rustup update stable && rustup default stable
      - name: regenerate cargo.lock
        run: cargo generate-lockfile
      - name: auto commit
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "[skip ci] updating app version to ${{ steps.version-bump.outputs.new_tag }}"
          branch: update-from-${{ github.sha }}
      # create PR using GitHub CLI
      - name: create PR with update info
        id: create-pr
        run: gh pr create --base rolling --head update-from-${{ github.sha }} --title 'Merge new update into rolling' --body 'Created by Github action'
        env:
          GH_TOKEN: ${{ secrets.ADMIN_RIGHTS_TOKEN }}
      # merge PR using GitHub CLI
      - name: merge PR with update info
        id: merge-pr
        run: gh pr merge --admin --merge --subject 'Merge update info' --delete-branch
        env:
          GH_TOKEN: ${{ secrets.ADMIN_RIGHTS_TOKEN }}
      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          token: ${{ secrets.ADMIN_RIGHTS_TOKEN }}
          generate_release_notes: true
          name: ${{ steps.version-bump.outputs.new_tag }}
          tag_name: ${{ steps.version-bump.outputs.new_tag }}
          prerelease: false
        env:
          GITHUB_REPOSITORY: ${{ github.repository }}