Skip to content

Workflow file for this run

# This workflow will build a package using Gradle and then publish it to OSSRH when a release is created
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle
name: Publish to OSSRH when released
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Extract secring.gpg to sign files
run: echo -n $SECRING_GPG | base64 --decode > micronaut-camunda-external-client-feature/secring.gpg
env:
SECRING_GPG: ${{ secrets.SECRING_GPG }}
# The GITHUB_REF tag comes in the format 'refs/tags/v0.0.1'. If we split on '/' and take the 3rd value, we can get the release version, e.g. v.0.0.1
# We then remove the leading "v", e.g. 0.0.1
- name: Build release based on tag and publish to OSSRH
run: |
echo "${GITHUB_ACTOR} is publishing tag ${GITHUB_REF}."
echo "${GITHUB_REF}" | cut -d "/" -f3 | grep --regexp '^v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+$' > /dev/null #Validate format with regular expression
RELEASE_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | sed 's/v//')
echo "New release version: ${RELEASE_VERSION}"
./gradlew -Pversion=${RELEASE_VERSION} build --warning-mode=all # value 'fail' would be better but the build even this breaks: "mn create-app mytest && cd mytest && ./gradlew clean build --warning-mode fail"
./gradlew -Pversion=${RELEASE_VERSION} -Psigning.password=${SIGNING_PWD} publish --info
env:
OSSRH_PWD: ${{ secrets.OSSRH_PWD }}
SIGNING_PWD: ${{ secrets.SIGNING_PWD }}