Skip to content

Release to the gradle plugins portal #20

Release to the gradle plugins portal

Release to the gradle plugins portal #20

Workflow file for this run

name: Release to the gradle plugins portal
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: Build with Gradle
run: ./gradlew build
- name: Decode GPG key
run: echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" | base64 --decode > ./secring.gpg
- 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/runner/work/TypedMaterials/TypedMaterials/secring.gpg" >> gradle.properties
echo "ossrhUsername=${{ secrets.OSSRH_USERNAME }}" >> gradle.properties
echo "ossrhPassword=${{ secrets.OSSRH_PASSWORD }}" >> gradle.properties
echo "gradle.publish.key=${{ secrets.GRADLE_PLUGIN_SIGNING_KEY_ID }}" >> gradle.properties
echo "gradle.publish.secret=${{ secrets.GRADLE_PLUGIN_SIGNING_PASSWORD }}" >> gradle.properties
- name: Publish package to Gradle plugin portal
run: ./gradlew publishPlugins
- name: Tag and update version
run: |
# Extract current version from plugin/build.gradle.kts
VERSION=$(grep "version = " plugin/build.gradle.kts | awk -F\" '{print $2}')
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
NEW_VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' OFS=.)
echo "New version: $NEW_VERSION"
# Update plugin/build.gradle.kts with the new version
sed -i "s/version = \"$VERSION\"/version = \"$NEW_VERSION\"/" plugin/build.gradle.kts
# Commit the change
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add plugin/build.gradle.kts
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 }}