.github/workflows/publish.yml #5
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
on: | |
[workflow_dispatch] | |
jobs: | |
create_staging_repository: | |
runs-on: ubuntu-latest | |
name: Create staging repository | |
outputs: | |
repository-id: ${{ steps.create.outputs.repository_id }} | |
steps: | |
- id: create | |
uses: nexus-actions/[email protected] | |
with: | |
base_url: https://s01.oss.sonatype.org/service/local/ | |
description: ${{ github.repository }}/${{ github.workflow }}#${{ github.run_number }} | |
username: ${{ secrets.NEXUS_ACTIONS_SONATYPE_USERNAME }} | |
password: ${{ secrets.NEXUS_ACTIONS_SONATYPE_PASSWORD }} | |
staging_profile_id: ${{ secrets.NEXUS_ACTIONS_SONATYPE_PROFILE_ID }} | |
macos: | |
runs-on: macos-latest | |
needs: create_staging_repository | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure JDK | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 14 | |
- name: Publish | |
run: | | |
./gradlew publishAllPublicationsToMavenRepository -PSONATYPE_REPOSITORY_ID=${{ needs.create_staging_repository.outputs.repository-id }} | |
env: | |
MANUAL_REPOSITORY: ${{ secrets.MANUAL_REPOSITORY }} | |
SONATYPE_REPOSITORY_ID: ${{ needs.create_staging_repository.outputs.repository-id }} | |
SONATYPE_USERNAME: ${{ secrets.NEXUS_ACTIONS_SONATYPE_USERNAME }} | |
SONATYPE_PASSWORD: ${{ secrets.NEXUS_ACTIONS_SONATYPE_PASSWORD }} | |
GPG_PRIVATE_KEY: ${{ secrets.NEXUS_ACTIONS_GPG_PRIVATE_KEY }} | |
GPG_PRIVATE_PASSWORD: ${{ secrets.NEXUS_ACTIONS_GPG_PRIVATE_PASSWORD }} | |
windows: | |
runs-on: windows-latest | |
needs: create_staging_repository | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure JDK | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 14 | |
- name: Publish | |
run: | | |
./gradlew publishMingwX64PublicationToMavenRepository -PSONATYPE_REPOSITORY_ID=${{ needs.create_staging_repository.outputs.repository-id }} | |
env: | |
MANUAL_REPOSITORY: ${{ secrets.MANUAL_REPOSITORY }} | |
SONATYPE_REPOSITORY_ID: ${{ needs.create_staging_repository.outputs.repository-id }} | |
SONATYPE_USERNAME: ${{ secrets.NEXUS_ACTIONS_SONATYPE_USERNAME }} | |
SONATYPE_PASSWORD: ${{ secrets.NEXUS_ACTIONS_SONATYPE_PASSWORD }} | |
GPG_PRIVATE_KEY: ${{ secrets.NEXUS_ACTIONS_GPG_PRIVATE_KEY }} | |
GPG_PRIVATE_PASSWORD: ${{ secrets.NEXUS_ACTIONS_GPG_PRIVATE_PASSWORD }} | |
finalize: | |
runs-on: ubuntu-latest | |
needs: [create_staging_repository,macos,windows] | |
if: ${{ always() && needs.create_staging_repository.result == 'success' }} | |
steps: | |
- name: Discard | |
if: ${{ needs.macos.result != 'success' || needs.windows.result != 'success' }} | |
uses: nexus-actions/[email protected] | |
with: | |
username: ${{ secrets.NEXUS_ACTIONS_SONATYPE_USERNAME }} | |
password: ${{ secrets.NEXUS_ACTIONS_SONATYPE_PASSWORD }} | |
staging_repository_id: ${{ needs.create_staging_repository.outputs.repository-id }} | |
- name: Release | |
if: ${{ needs.macos.result == 'success' && needs.windows.result == 'success' }} | |
uses: nexus-actions/[email protected] | |
with: | |
base_url: https://s01.oss.sonatype.org/service/local/ | |
username: ${{ secrets.NEXUS_ACTIONS_SONATYPE_USERNAME }} | |
password: ${{ secrets.NEXUS_ACTIONS_SONATYPE_PASSWORD }} | |
staging_repository_id: ${{ needs.create_staging_repository.outputs.repository-id }} |