CI-release #18
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
name: CI-release | |
on: | |
# Release event https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#release | |
# Note: The `prereleased` type will not trigger for pre-releases published from draft releases, but the `published` | |
# type will trigger. If you want a workflow to run when stable and pre-releases publish, subscribe to `published` | |
# instead of `released` and `prereleased`. | |
release: | |
types: [ published ] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to release' | |
required: true | |
# Environment variables | |
# https://docs.github.com/en/actions/learn-github-actions/variables | |
jobs: | |
release-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check semver version in tag | |
run: | | |
prefix="v" | |
tag_name="${{ github.event.inputs.tag || github.event.release.tag_name }}" | |
semver_regex="(0|[1-9]\d*)+\.(0|[1-9]\d*)+\.(0|[1-9]\d*)+(-(([a-z-][\da-z-]+|[\da-z-]+[a-z-][\da-z-]*|0|[1-9]\d*)(\.([a-z-][\da-z-]+|[\da-z-]+[a-z-][\da-z-]*|0|[1-9]\d*))*))?(\\+([\da-z-]+(\.[\da-z-]+)*))?" | |
echo "Checking version: $semver_regex" | |
echo "$tag_name" | grep -Eq "^$prefix$semver_regex\$" | |
shell: bash | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.tag || github.event.release.tag_name }} | |
fetch-depth: 50 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'zulu' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Publish to Staging Repository | |
if: success() | |
env: | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} | |
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.ORG_GRADLE_PROJECT_OSSRHUSERNAME }} | |
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.ORG_GRADLE_PROJECT_OSSRHPASSWORD }} | |
# com.javiersc.semver.gradle.plugin should pick the actual tag | |
run: ./gradlew publish -Ppublish.central=true --stacktrace | |
# Don't forget to deploy the release to central | |
# * 'Close' the repo to trigger the evaluations of to components against the requirements | |
# * 'Release' the repo | |
# https://central.sonatype.org/publish/release/ | |
# If any errors occur, check the FAQ | |
# https://central.sonatype.org/faq/400-error/ |