Publish and release #4
This file contains hidden or 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: Publish | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| publish: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Make Gradle wrapper executable | |
| run: chmod +x ./gradlew | |
| - name: Build and test | |
| run: ./gradlew build allTests --stacktrace | |
| - name: Verify release version | |
| if: github.event_name == 'release' | |
| run: | | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| PROJECT_VERSION=$(./gradlew properties -q | awk '/^version:/ { print $2 }') | |
| echo "Release tag version: $TAG_VERSION" | |
| echo "Gradle project version: $PROJECT_VERSION" | |
| if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then | |
| echo "Release tag and Gradle version do not match." | |
| exit 1 | |
| fi | |
| - name: Publish to Maven Central | |
| run: ./gradlew publishToMavenCentral --stacktrace | |
| env: | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} |