Release Library #13
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: Release Library | |
on: | |
workflow_dispatch: | |
env: | |
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | |
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} | |
ORG_GRADLE_PROJECT_isRelease: true | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: Set up Gradle | |
uses: gradle/gradle-build-action@v3 | |
- name: Create Nexus staging repository | |
id: create-nexus-staging | |
uses: nexus-actions/create-nexus-staging-repo@v1 | |
with: | |
username: ${{ secrets.SONATYPE_USERNAME }} | |
password: ${{ secrets.SONATYPE_PASSWORD }} | |
staging_profile_id: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} | |
description: Created by $GITHUB_WORKFLOW ($GITHUB_ACTION) for $GITHUB_REPOSITORY | |
base_url: https://s01.oss.sonatype.org/service/local/ | |
- name: Publish artifacts to Sonatype | |
id: publish | |
run: ./gradlew publishAllPublicationsToSonatypeRepository | |
env: | |
ORG_GRADLE_PROJECT_sonatypeStagingRepositoryId: ${{ steps.create-nexus-staging.outputs.repository_id }} | |
- name: Discard Nexus staging repository | |
if: ${{ failure() && steps.publish.conclusion == 'failure' }} | |
uses: nexus-actions/drop-nexus-staging-repo@v1 | |
with: | |
username: ${{ secrets.SONATYPE_USERNAME }} | |
password: ${{ secrets.SONATYPE_PASSWORD }} | |
staging_repository_id: ${{ steps.create-nexus-staging.outputs.repository_id }} | |
base_url: https://s01.oss.sonatype.org/service/local/ | |
- name: Release Nexus repository | |
uses: nexus-actions/release-nexus-staging-repo@v1 | |
with: | |
username: ${{ secrets.SONATYPE_USERNAME }} | |
password: ${{ secrets.SONATYPE_PASSWORD }} | |
staging_repository_id: ${{ steps.create-nexus-staging.outputs.repository_id }} | |
base_url: https://s01.oss.sonatype.org/service/local/ | |
- name: Extract version from build.gradle.kts | |
id: extract_version | |
run: | | |
version=$(sed -n 's/.*version = "\([0-9.]*\).*/\1/p' compose-remember-setting/build.gradle.kts) | |
echo "VERSION=$version" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.TOKEN_RELEASES }} | |
tag: ${{ env.VERSION }} | |
commit: ${{ github.sha }} | |
generateReleaseNotes: true | |
makeLatest: true |