|
| 1 | +name: Master branch CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'master' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Master Branch CI |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + - uses: actions/cache@v1 |
| 17 | + with: |
| 18 | + path: ~/.m2/repository |
| 19 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 20 | + restore-keys: | |
| 21 | + ${{ runner.os }}-maven- |
| 22 | + - name: Set up JDK 1.8 |
| 23 | + uses: actions/setup-java@v1 |
| 24 | + with: |
| 25 | + java-version: 1.8 |
| 26 | + server-id: github |
| 27 | + server-username: GITHUB_ACTOR |
| 28 | + server-password: GITHUB_TOKEN |
| 29 | + - name: Maven Build |
| 30 | + run: mvn clean install -DskipTests=true -Ddockerfile.skip=true -B -V |
| 31 | + env: |
| 32 | + GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} |
| 33 | + - name: Maven Verify |
| 34 | + run: mvn verify -B |
| 35 | + - name: Configure git |
| 36 | + run: | |
| 37 | + echo "Git checkout branch ${GITHUB_REF##*/}, commit ${GITHUB_SHA} was pushed by ${GITHUB_ACTOR}" |
| 38 | + git checkout ${GITHUB_REF##*/} |
| 39 | + echo "Git reset hard to ${GITHUB_SHA}" |
| 40 | + git reset --hard ${GITHUB_SHA} |
| 41 | + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" |
| 42 | + git config --global user.name "${GITHUB_ACTOR}" |
| 43 | + - name: Prepare release |
| 44 | + id: prepare_release |
| 45 | + run: | |
| 46 | + mvn --batch-mode build-helper:parse-version release:prepare -P release \ |
| 47 | + -DreleaseVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion} \ |
| 48 | + -DdevelopmentVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT \ |
| 49 | + -DautoVersionSubmodules=true -Darguments="-DskipTests=true" |
| 50 | + echo ::set-output name=release_tag::$(git describe --tags --abbrev=0) |
| 51 | + - name: Perform release |
| 52 | + run: mvn --batch-mode release:perform -P release -Darguments="-DskipTests=true -Ddocker.image.extra-tag=master" |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} |
| 56 | + - name: Rollback release |
| 57 | + if: failure() |
| 58 | + run: | |
| 59 | + mvn release:rollback || echo "nothing to rollback" |
| 60 | + if [ ! -z "${{ steps.prepare_release.outputs.release_tag }}" ] |
| 61 | + then |
| 62 | + git tag -d ${{ steps.prepare_release.outputs.release_tag }} |
| 63 | + git push origin :refs/tags/${{ steps.prepare_release.outputs.release_tag }} |
| 64 | + fi |
0 commit comments