Add Maven Central publishing config and release workflow #1
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - uses: gradle/actions/setup-gradle@v4 | |
| - run: ./gradlew test | |
| - run: ./gradlew spotlessCheck | |
| - name: Publish to staging | |
| run: ./gradlew publishAllPublicationsToStagingRepository | |
| env: | |
| ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} | |
| - name: Create bundle for Maven Central | |
| run: | | |
| cd build/staging-deploy | |
| zip -r ../../bundle.zip . | |
| - name: Publish to Maven Central | |
| run: | | |
| curl -s --fail \ | |
| -u "${{ secrets.CENTRAL_USERNAME }}:${{ secrets.CENTRAL_PASSWORD }}" \ | |
| -F "bundle=@bundle.zip" \ | |
| "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC&name=dev.peekapi:peekapi:${{ github.ref_name }}" | |
| - name: Create GitHub Release | |
| run: gh release create "${{ github.ref_name }}" --generate-notes | |
| env: | |
| GH_TOKEN: ${{ github.token }} |