|
| 1 | +name: Publish to Maven Central |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + publish: |
| 9 | + name: Publish Release Artifacts |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + # Step 1 |
| 14 | + # This is optional and only if you want to set the timezone |
| 15 | + - name: Setup timezone |
| 16 | + run: | |
| 17 | + sudo timedatectl set-timezone Europe/Berlin |
| 18 | + timedatectl |
| 19 | + # Step 2 |
| 20 | + # Reguired step |
| 21 | + - name: Check out the repo |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + # Step 3 |
| 25 | + # Optional step |
| 26 | + - name: Validate Gradle wrapper |
| 27 | + uses: gradle/wrapper-validation-action@v1 |
| 28 | + |
| 29 | + # Step 4 |
| 30 | + # Reguired step |
| 31 | + - name: Set up Java 8 JDK |
| 32 | + uses: actions/setup-java@v2 |
| 33 | + with: |
| 34 | + java-version: '8' |
| 35 | + distribution: 'temurin' |
| 36 | + architecture: x64 |
| 37 | + cache: 'gradle' |
| 38 | + check-latest: true |
| 39 | + |
| 40 | + # Step 5 |
| 41 | + # Optional step, but recommended as user often commit the gradle wrapper jar without exevute permissions. |
| 42 | + - name: Change wrapper permissions |
| 43 | + run: chmod +x ./gradlew |
| 44 | + |
| 45 | + # Step 6 |
| 46 | + # Reguired step |
| 47 | + - name: Decode GPG Key |
| 48 | + run: | |
| 49 | + mkdir -p ~/.gradle/ |
| 50 | + echo "${{secrets.OSSRH_GPG_SECRET_KEY}}" > ~/.gradle/secring.gpg.b64 |
| 51 | + base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg |
| 52 | + # Step 7 |
| 53 | + # Obviously reguired step |
| 54 | + - name: Publish package |
| 55 | + # wraped the signing.password with single quotes as the password could contain special characters |
| 56 | + run: ./gradlew publish -Psigning.keyId=${{secrets.OSSRH_GPG_SECRET_KEY_ID}} -Psigning.password='${{secrets.OSSRH_GPG_SECRET_KEY_PASSWORD}}' -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) --warn --stacktrace |
| 57 | + env: |
| 58 | + MAVEN_USERNAME: ${{secrets.OSSRH_USERNAME}} |
| 59 | + MAVEN_PASSWORD: ${{secrets.OSSRH_PASSWORD}} |
| 60 | + |
| 61 | + # Step 8 |
| 62 | + # Optional step, will enable you to see what you have released as well here on GitHub |
| 63 | + - name: Upload Artifacts |
| 64 | + uses: actions/upload-artifact@v2 |
| 65 | + with: |
| 66 | + name: release-build-libs |
| 67 | + path: build/libs |
| 68 | + retention-days: 3 |
0 commit comments