Skip to content

Java release with Gradle #45

Java release with Gradle

Java release with Gradle #45

Workflow file for this run

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
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
run: ./gradlew --info --stacktrace build
- name: Prepare Central bundle
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
run: ./gradlew --info --stacktrace prepareCentralBundle
- name: Grant execute permission for upload script
run: chmod +x .github/scripts/upload_central.sh
- name: Upload bundle via Central Publisher API (USER_MANAGED)
run: .github/scripts/upload_central.sh "build/central-bundle.zip"
env:
CENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
- 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 }}