|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + type: |
| 7 | + description: 'New version type [major | minor | patch]' |
| 8 | + required: true |
| 9 | + default: 'patch' |
| 10 | +jobs: |
| 11 | + bumpVersion: |
| 12 | + runs-on: ubuntu-20.04 |
| 13 | + steps: |
| 14 | + - run: | |
| 15 | + echo "New version type: ${{ github.event.inputs.type }}" |
| 16 | +
|
| 17 | + - name: Branch Protection Bot - Temporarily disable "include administrators" branch protection |
| 18 | + uses: benjefferies/branch-protection-bot@1.0.7 |
| 19 | + if: always() |
| 20 | + with: |
| 21 | + access_token: ${{ secrets.GH_RELEASE_TOKEN }} |
| 22 | + enforce_admins: false |
| 23 | + branch: main |
| 24 | + |
| 25 | + - name: Setup checkout |
| 26 | + uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + token: ${{ secrets.GH_RELEASE_TOKEN }} |
| 29 | + |
| 30 | + - name: Config git |
| 31 | + run: | |
| 32 | + git config --local user.email "62586190+process-analytics-bot@users.noreply.github.com" |
| 33 | + git config --local user.name "process-analytics-bot" |
| 34 | + git config pull.rebase true |
| 35 | +
|
| 36 | + - name: Checkout main |
| 37 | + run: git checkout main && git pull --tag |
| 38 | + |
| 39 | + - name: Generate new version |
| 40 | + id: release_version |
| 41 | + uses: zwaldowski/semver-release-action@v3 |
| 42 | + with: |
| 43 | + dry_run: true |
| 44 | + bump: ${{ inputs.type }} |
| 45 | + prefix: v |
| 46 | + github_token: ${{ secrets.GH_RELEASE_TOKEN }} |
| 47 | + |
| 48 | + - name: Update with the release version |
| 49 | + run: | |
| 50 | + CURRENT_VERSION=$(grep Version DESCRIPTION | sed 's/Version: \(.*\).9000/\1/g') |
| 51 | + sed -i -E "s/$CURRENT_VERSION/${{ steps.release_version.outputs.version }}/g" README.md |
| 52 | + sed -i -E 's/Version: .*/Version: ${{ steps.release_version.outputs.version }}/g' DESCRIPTION |
| 53 | +
|
| 54 | + - name: Commit with the release version |
| 55 | + run: | |
| 56 | + git add README.md |
| 57 | + git add DESCRIPTION |
| 58 | + git commit -m "[RELEASE] Set the release version to ${{ steps.release_version.outputs.version }}" |
| 59 | + git push |
| 60 | +
|
| 61 | + - name: Tag ${{ steps.release_version.outputs.version }} |
| 62 | + run: | |
| 63 | + git tag -a ${{ steps.release_version.outputs.version_tag }} -m "[RELEASE] ${{ steps.release_version.outputs.version }}" |
| 64 | + git push && git push --tags |
| 65 | +
|
| 66 | + - name: Update with the development version |
| 67 | + run: |- |
| 68 | + sed -i -E 's/Version: .*/Version: ${{ steps.release_version.outputs.version }}.9000/g' DESCRIPTION |
| 69 | +
|
| 70 | + - name: Commit with the development version |
| 71 | + run: | |
| 72 | + git add DESCRIPTION |
| 73 | + git commit -m "[RELEASE] Set the development version to ${{ steps.release_version.outputs.version }}.9000" |
| 74 | + git push |
| 75 | +
|
| 76 | + - name: Branch Protection Bot - Reenable "include administrators" branch protection |
| 77 | + uses: benjefferies/branch-protection-bot@1.0.7 |
| 78 | + if: always() # Force to always run this step to ensure "include administrators" is always turned back on |
| 79 | + with: |
| 80 | + access_token: ${{ secrets.GH_RELEASE_TOKEN }} |
| 81 | + enforce_admins: true |
| 82 | + branch: main |
0 commit comments