Skip to content

Commit

Permalink
#412: Add worflow to release metal automatically but with manual trig…
Browse files Browse the repository at this point in the history
…ger.

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.
  • Loading branch information
mvanaken committed Feb 12, 2024
1 parent e45c527 commit a68b1f0
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a68b1f0

Please sign in to comment.