Java release with Gradle #41
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: Java release with Gradle | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Decode GPG key | |
| run: echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" | base64 --decode > $HOME/secring.gpg | |
| - name: Debug show GPG key file | |
| run: ls -l $HOME/secring.gpg || true | |
| - name: Create gradle.properties | |
| run: | | |
| echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties | |
| echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties | |
| echo "signing.secretKeyRingFile=$HOME/secring.gpg" >> gradle.properties | |
| echo "ossrhUsername=${{ secrets.OSSRH_USERNAME }}" >> gradle.properties | |
| echo "ossrhPassword=${{ secrets.OSSRH_PASSWORD }}" >> gradle.properties | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Prepare Central bundle | |
| run: ./gradlew --info --stacktrace prepareCentralBundle | |
| - name: Upload bundle to Central Portal | |
| env: | |
| CENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| CENTRAL_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
| run: | | |
| chmod +x .github/scripts/upload_central.sh | |
| .github/scripts/upload_central.sh build/central-bundle.zip | |
| - name: Tag and update version | |
| run: | | |
| # Extract current version from gradle.properties | |
| VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2) | |
| echo "Current version: $VERSION" | |
| # Create and push the tag for the current version | |
| git tag "v$VERSION" | |
| git push origin "v$VERSION" | |
| # Increment version for the next cycle (bump patch) | |
| NEW_VERSION=$(echo $VERSION | awk -F. '{ $NF = $NF + 1; print $0 }' OFS='.') | |
| echo "New version: $NEW_VERSION" | |
| # Update gradle.properties with the new version | |
| sed -i "s/^version=.*/version=$NEW_VERSION/" gradle.properties | |
| # Commit the change | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add gradle.properties | |
| git commit -m "Increment version to $NEW_VERSION [skip ci]" | |
| # Push the commit | |
| git push origin HEAD:${{ github.ref }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |