|
| 1 | +name: Release beta |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + approval: |
| 7 | + description: 'Do you really want to release a BETA from configured BRANCH?' |
| 8 | + required: true |
| 9 | + default: 'NO' |
| 10 | + |
| 11 | +env: |
| 12 | + MVN_ARGS: --batch-mode --errors --fail-fast --no-transfer-progress |
| 13 | + |
| 14 | +jobs: |
| 15 | + default: |
| 16 | + |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Verify approval |
| 21 | + run: "[[ $(echo ${{ github.event.inputs.approval }} | tr 'a-z' 'A-Z') == 'YES' ]]" |
| 22 | + |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + token: ${{ secrets.TRIGGER_ACTIONS_GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - name: Verify for release or hotfix branch |
| 29 | + run: "[[ $( git branch --show-current ) =~ ^release.*|^hotfix.* ]]" |
| 30 | + |
| 31 | + - uses: actions/setup-java@v1 |
| 32 | + with: |
| 33 | + java-version: 8 |
| 34 | + |
| 35 | + - name: Cache local Maven repository |
| 36 | + uses: actions/cache@v2 |
| 37 | + with: |
| 38 | + path: ~/.m2/repository |
| 39 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 40 | + restore-keys: ${{ runner.os }}-maven- |
| 41 | + |
| 42 | + - name: Configure Git user |
| 43 | + run: | |
| 44 | + git config user.email "ops+githubactions@retest.de" |
| 45 | + git config user.name "retest release github action" |
| 46 | +
|
| 47 | + - id: next_beta |
| 48 | + name: Find next beta version |
| 49 | + run: | |
| 50 | + # get next stable release version from pom.xml |
| 51 | + RELEASE_VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//' ) |
| 52 | + # find last beta for this version using git tags. Prefix with 0 als default for next line |
| 53 | + LAST_BETA_TAG=0$( git for-each-ref --sort=-taggerdate --count=1 --format '%(refname:short)' "refs/tags/v${RELEASE_VERSION}-beta.*" ) |
| 54 | + # Create string for beta version |
| 55 | + NEXT_BETA="$RELEASE_VERSION-beta.$((1+"${LAST_BETA_TAG/v$RELEASE_VERSION-beta./}"))" |
| 56 | + echo "::set-output name=version::$NEXT_BETA" |
| 57 | +
|
| 58 | + - name: Create beta release tag |
| 59 | + run: | |
| 60 | + mvn versions:set -DnewVersion=${{ steps.next_beta.outputs.version }} -DgenerateBackupPoms=false |
| 61 | + git commit -a -m "ci: release ${{ steps.next_beta.outputs.version }}" |
| 62 | + git tag -a v${{ steps.next_beta.outputs.version }} -m "ci: tag beta release ${{ steps.next_beta.outputs.version }}" |
| 63 | + git push --tags |
0 commit comments