Skip to content

v1.1.0-rc.1

v1.1.0-rc.1 #119

Workflow file for this run

name: Release
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
versionTag:
type: string
description: Version tag to use for the Docker image and Maven JAR
required: true
tagAsLatest:
type: boolean
description: Tag the Docker image as latest
required: true
default: false
publishToMaven:
type: boolean
description: Publish the JAR to Maven Central
required: true
default: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: Add Homebrew to PATH
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: Setup Vault Container
run: |-
brew tap hashicorp/tap
brew install hashicorp/tap/vault
- name: Build with Gradle
run: ./gradlew clean build --refresh-dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set Image Details
id: ci-release-create-outputs
shell: bash
run: |
VERSION=$( echo ${{ github.event.release.tag_name }} | sed -e 's/^v//' )
if [ "$VERSION" == "" ] ; then
VERSION=$( echo ${{ github.event.inputs.versionTag }} | sed -e 's/^v//' )
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
TAG_DOCKER_IMAGE_AS_LATEST=false
if [[ "${{ inputs.tagAsLatest }}" == "true" || ("${{github.event_name}}" == "release" && "${{github.event.release.prerelease}}" == "false") ]] ; then
TAG_DOCKER_IMAGE_AS_LATEST=true
fi
echo "tagAsLatest=${TAG_DOCKER_IMAGE_AS_LATEST}" >> $GITHUB_OUTPUT
- name: Build and Push Docker Image
env:
JIB_AUTH_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
JIB_AUTH_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKER_IMAGE_NAME: provenanceio/p8e-cee-api:${{ steps.ci-release-create-outputs.outputs.version }}
TAG_DOCKER_IMAGE_AS_LATEST: ${{ steps.ci-release-create-outputs.outputs.tagAsLatest }}
run: ./gradlew :service:jib -Djib.console=plain -Pversion=${VERSION}
- name: Install gpg secret key
if: inputs.publishToMaven || github.event_name == 'release'
run: |
export GPG_TTY=$(tty)
echo -n "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 --decode | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
echo -n "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 --decode > $GITHUB_WORKSPACE/release.gpg
- name: Publish to Maven Central
if: inputs.publishToMaven || github.event_name == 'release'
run: |
./gradlew publishToSonatype -Pversion=${{ steps.ci-release-create-outputs.outputs.version }} $(if [ "${{github.event.release.prerelease}}" = "true" ]; then echo 'closeSonatypeStagingRepository'; else echo 'closeAndReleaseSonatypeStagingRepository'; fi) \
-Psigning.keyId=B7D30ABE -Psigning.password="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg \
--info
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}