-
Notifications
You must be signed in to change notification settings - Fork 43
63 lines (51 loc) · 2.24 KB
/
release-beta.yml
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
name: Release beta
on:
workflow_dispatch:
inputs:
approval:
description: 'Do you really want to release a BETA from configured BRANCH?'
required: true
default: 'NO'
env:
MVN_ARGS: --batch-mode --errors --fail-fast --no-transfer-progress
jobs:
default:
runs-on: ubuntu-latest
steps:
- name: Verify approval
run: "[[ $(echo ${{ github.event.inputs.approval }} | tr 'a-z' 'A-Z') == 'YES' ]]"
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.TRIGGER_ACTIONS_GITHUB_TOKEN }}
- name: Verify for release or hotfix branch
run: "[[ $( git branch --show-current ) =~ ^release.*|^hotfix.* ]]"
- uses: actions/setup-java@v1
with:
java-version: 8
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "retest release github action"
- id: next_beta
name: Find next beta version
run: |
# get next stable release version from pom.xml
RELEASE_VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//' )
# find last beta for this version using git tags. Prefix with 0 als default for next line
LAST_BETA_TAG=0$( git for-each-ref --sort=-taggerdate --count=1 --format '%(refname:short)' "refs/tags/v${RELEASE_VERSION}-beta.*" )
# Create string for beta version
NEXT_BETA="$RELEASE_VERSION-beta.$((1+"${LAST_BETA_TAG/v$RELEASE_VERSION-beta./}"))"
echo "::set-output name=version::$NEXT_BETA"
- name: Create beta release tag
run: |
mvn versions:set -DnewVersion=${{ steps.next_beta.outputs.version }} -DgenerateBackupPoms=false
git commit -a -m "ci: release ${{ steps.next_beta.outputs.version }}"
git tag -a v${{ steps.next_beta.outputs.version }} -m "ci: tag beta release ${{ steps.next_beta.outputs.version }}"
git push --tags