Publish to OSSRH when released #72
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Extract secring.gpg to sign files | |
run: echo -n $SECRING_GPG | base64 --decode > micronaut-camunda-bpm-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 -Dorg.gradle.internal.http.socketTimeout=180000 -Dorg.gradle.internal.http.connectionTimeout=180000 | |
env: | |
OSSRH_TOKEN_USER: ${{ secrets.OSSRH_TOKEN_USER }} | |
OSSRH_TOKEN_PWD: ${{ secrets.OSSRH_TOKEN_PWD }} |