|
| 1 | +name: Bump version |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ develop ] |
| 6 | + types: |
| 7 | + - opened |
| 8 | + - reopened |
| 9 | + - synchronize |
| 10 | + - ready_for_review |
| 11 | + - labeled |
| 12 | + |
| 13 | +jobs: |
| 14 | + try-to-bump: |
| 15 | + if: contains(github.event.pull_request.labels.*.name, 'bump-version') |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + ref: ${{ github.head_ref }} |
| 22 | + - name: check diff |
| 23 | + id: check_diff |
| 24 | + run: | |
| 25 | + set -euo pipefail |
| 26 | +
|
| 27 | + # fetch develop branch so that we can diff against later |
| 28 | + git fetch origin develop |
| 29 | +
|
| 30 | + echo 'checking verion changes in diff...' |
| 31 | +
|
| 32 | + # check if version changed in version.go |
| 33 | + # note: the grep will fail if use \d instead of [0-9] |
| 34 | + git diff HEAD..origin/develop --text --no-ext-diff --unified=0 --no-prefix params/version.go | grep -E '^\+VersionPatch = "v[0-9]+"$' && true |
| 35 | +
|
| 36 | + exit_code=$? |
| 37 | +
|
| 38 | + # auto bump if version is not bumped manually |
| 39 | + echo '> require auto version bump?' |
| 40 | +
|
| 41 | + if [ $exit_code -eq 0 ]; then |
| 42 | + echo '> no, already bumped' |
| 43 | + echo "result=no-bump" >> "$GITHUB_OUTPUT" |
| 44 | + else |
| 45 | + echo '> yes' |
| 46 | + echo "result=bump" >> "$GITHUB_OUTPUT" |
| 47 | + fi |
| 48 | + - name: Install Node.js 16 |
| 49 | + if: steps.check_diff.outputs.result == 'bump' |
| 50 | + uses: actions/setup-node@v3 |
| 51 | + with: |
| 52 | + node-version: 16 |
| 53 | + - name: bump version in params/version.go |
| 54 | + if: steps.check_diff.outputs.result == 'bump' |
| 55 | + run: node .github/scripts/bump_version_dot_go.mjs |
| 56 | + |
| 57 | + # Commits made by this Action do not trigger new Workflow runs |
| 58 | + - uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a |
| 59 | + if: steps.check_diff.outputs.result == 'bump' |
| 60 | + with: |
| 61 | + skip_fetch: true # already did fetch in check diff |
| 62 | + file_pattern: "params/version.go" |
| 63 | + commit_message: "chore: auto version bump [bot]" |
0 commit comments