From a68b1f0014ff29d99752a058d7236469a71b6d3e Mon Sep 17 00:00:00 2001 From: Marja van Aken Date: Mon, 12 Feb 2024 15:07:30 +0100 Subject: [PATCH] #412: Add worflow to release metal automatically but with manual trigger. This workflow may only be triggered manually. The values of all the secret variables are already included within GitHub. Only the license year replacement and version within README is not implemented yet. --- .github/workflows/release.yml | 87 +++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..0d08e3eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,87 @@ +# General workflow to build Metal + +name: Metal build + +on: + workflow_dispatch: + inputs: + doRelease: + description: 'Do release' + required: false + type: boolean + javaVersion: + description: 'Java version' + required: true + default: '11' + type: choice + options: + - '11' + - '17' + javaDistribution: + description: 'Java distribution' + required: true + default: 'corretto' + type: choice + options: + - 'corretto' + - 'temurin' + + +jobs: + release: + runs-on: ubuntu-latest + if: github.ref_name == 'main' && ${{ inputs.doRelease }} + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Cache + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: ${{ inputs.javaVersion }} + distribution: ${{ inputs.javaDistribution }} + + # See more details about setting secret keys https://gist.github.com/sualeh/ae78dc16123899d7942bc38baba5203c + - name: Install gpg secret key + id: install-secret-key + run: | + # Install gpg secret key + cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import + # Verify gpg secret key + gpg --list-secret-keys --keyid-format LONG + + - name: Update License headers + run: | + mavenVersion=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout); + version=${mavenVersion%%-SNAPSHOT}; + echo Update headers here. + echo Update README here. + + - name: Release prepare + run: mvn -B release:prepare release:clean + + - name: Checkout to latest tag + run: git checkout $(git describe --tags --abbrev=0) + + - name: Publish to Maven Central Repository + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + run: | + mvn \ + --no-transfer-progress \ + --batch-mode \ + -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \ + deploy -Prelease +