Update gradle/publish.gradle #109
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: build | |
| env: | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release: | |
| type: boolean | |
| default: false | |
| description: Whether to make a release | |
| pull_request: | |
| push: | |
| paths-ignore: | |
| - "README.md" | |
| - ".gitignore" | |
| jobs: | |
| build: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: VERSION file changed | |
| id: version-file-changed | |
| uses: tj-actions/changed-files@v42 | |
| with: | |
| files: VERSION | |
| - name: Should make release? | |
| if: | | |
| github.event_name == 'workflow_dispatch' && github.event.inputs.release || | |
| (github.ref == 'refs/heads/main' && | |
| github.event_name == 'push' && | |
| steps.version-file-changed.outputs.any_changed == 'true') | |
| run: echo make_release=true >> "$GITHUB_ENV" | |
| - name: Get version | |
| if: env.make_release | |
| run: echo VERSION="$(head VERSION)" >> "$GITHUB_ENV" | |
| - name: Gradle Build and Test | |
| run: | | |
| ./gradlew build --info --stacktrace | |
| - name: Release (GitHub) | |
| if: env.make_release | |
| id: github_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: ${{ env.VERSION }} | |
| tag_name: ${{ env.VERSION }} | |
| - name: Prepare PGP Keyring file | |
| if: env.make_release | |
| env: | |
| GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} | |
| run: | | |
| echo "${GPG_KEY_CONTENTS}" | base64 -d > signing-key.gpg | |
| shell: bash | |
| - name: Publish to Maven Central | |
| if: env.make_release | |
| run: | | |
| ./gradlew \ | |
| publishToSonatypeRepository \ | |
| closeAndReleaseSonatypeStagingRepository \ | |
| --info --stacktrace | |
| env: | |
| OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
| SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | |
| SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} | |
| SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} |