|
| 1 | +# |
| 2 | +# Copyright 2021 The original authors |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | + |
| 17 | +name: Trigger |
| 18 | + |
| 19 | +on: |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + branch: |
| 23 | + description: "Branch to release from" |
| 24 | + required: true |
| 25 | + default: "main" |
| 26 | + version: |
| 27 | + description: "Release version" |
| 28 | + required: true |
| 29 | + |
| 30 | +jobs: |
| 31 | + build: |
| 32 | + name: Build |
| 33 | + runs-on: ubuntu-latest |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v2 |
| 38 | + |
| 39 | + - name: Setup Java |
| 40 | + uses: actions/setup-java@v2 |
| 41 | + with: |
| 42 | + java-version: 17 |
| 43 | + distribution: 'zulu' |
| 44 | + |
| 45 | + - name: Cache Maven |
| 46 | + uses: actions/cache@v2 |
| 47 | + with: |
| 48 | + path: ~/.m2 |
| 49 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 50 | + restore-keys: ${{ runner.os }}-m2 |
| 51 | + |
| 52 | + - name: Build |
| 53 | + run: mvn --no-transfer-progress -B --file pom.xml verify |
| 54 | + |
| 55 | + tag: |
| 56 | + name: Tag |
| 57 | + needs: build |
| 58 | + runs-on: ubuntu-latest |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout sources |
| 62 | + uses: actions/checkout@v2 |
| 63 | + with: |
| 64 | + # required for triggering release workflow on tagging |
| 65 | + token: ${{ secrets.GIT_ACCESS_TOKEN }} |
| 66 | + |
| 67 | + - name: Setup Java |
| 68 | + uses: actions/setup-java@v2 |
| 69 | + with: |
| 70 | + java-version: 17 |
| 71 | + distribution: 'zulu' |
| 72 | + |
| 73 | + - name: Cache Maven |
| 74 | + uses: actions/cache@v2 |
| 75 | + with: |
| 76 | + path: ~/.m2 |
| 77 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 78 | + restore-keys: ${{ runner.os }}-m2 |
| 79 | + |
| 80 | + - name: Create tag |
| 81 | + run: | |
| 82 | + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* |
| 83 | + BRANCH=${{ github.event.inputs.branch }} |
| 84 | + VERSION=${{ github.event.inputs.version }} |
| 85 | + echo "Releasing $VERSION from $BRANCH branch" |
| 86 | + git checkout $BRANCH |
| 87 | + mvn -B versions:set versions:commit -DnewVersion=$VERSION |
| 88 | + git config --global user.email "[email protected]" |
| 89 | + git config --global user.name "moditect-release-bot" |
| 90 | + git commit -a -m "Releasing version $VERSION" |
| 91 | + git tag v$VERSION |
| 92 | + git push origin $BRANCH |
| 93 | + git push origin v$VERSION |
0 commit comments