|
| 1 | +# |
| 2 | +# Copyright 2022 ABSA Group Limited |
| 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: Release |
| 18 | + |
| 19 | +on: |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +defaults: |
| 23 | + run: |
| 24 | + shell: bash |
| 25 | + |
| 26 | +jobs: |
| 27 | + release-sbt: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + name: Release Scala artifacts |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + ref: master |
| 35 | + |
| 36 | + - name: Setup JDK and sbt |
| 37 | + uses: actions/setup-java@v4 |
| 38 | + with: |
| 39 | + distribution: temurin |
| 40 | + java-version: 8 |
| 41 | + cache: sbt |
| 42 | + |
| 43 | + - name: Import GPG Key |
| 44 | + run: | |
| 45 | + echo "${{ secrets.ABSA_OSS_CI_CD_BOT_GPG_KEY }}" > gpg-secret-key.asc |
| 46 | + gpg --import --batch gpg-secret-key.asc && rm -rf gpg-secret-key.asc |
| 47 | + mkdir -p ~/.gnupg |
| 48 | +
|
| 49 | + - name: Setup SonaType config |
| 50 | + run: | |
| 51 | + mkdir -p ~/.sbt/1.0 |
| 52 | + echo "${{ secrets.SONATYPE_CONFIG }}" | base64 --decode > ~/.sbt/1.0/sonatype.sbt |
| 53 | +
|
| 54 | + - name: Checkout the release branch |
| 55 | + run: | |
| 56 | + VERSION=$(grep "ThisBuild / version" version.sbt | cut -d\" -f2 | sed 's/-SNAPSHOT//') |
| 57 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 58 | + git config --global user.email "[email protected]" |
| 59 | + git config --global user.name "CI/CD bot" |
| 60 | + git fetch origin release/$VERSION |
| 61 | + git checkout release/$VERSION |
| 62 | +
|
| 63 | + - name: Run the release plugin |
| 64 | + run: sbt releaseNow |
| 65 | + |
| 66 | + create-pr: |
| 67 | + needs: [ "release-sbt" ] |
| 68 | + runs-on: ubuntu-latest |
| 69 | + name: Create Pull Request |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout code |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + ref: master |
| 76 | + |
| 77 | + - name: Checkout the release branch |
| 78 | + id: release_branch3 |
| 79 | + run: | |
| 80 | + VERSION=$(grep "ThisBuild / version" version.sbt | cut -d\" -f2 | sed 's/-SNAPSHOT//') |
| 81 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 82 | + git config --global user.email "[email protected]" |
| 83 | + git config --global user.name "CI/CD bot" |
| 84 | + git fetch origin release/$VERSION |
| 85 | + git checkout release/$VERSION |
| 86 | +
|
| 87 | + - name: Create Pull Request |
| 88 | + run: gh pr create -B master -H "release/$VERSION" --title "Release Cobrix v$VERSION" --body 'Created by Github action' |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + VERSION: ${{ steps.release_branch3.outputs.VERSION }} |
0 commit comments