Skip to content

Make Gradle runner resilient to local JDK and remove Foojay plugin #37

Make Gradle runner resilient to local JDK and remove Foojay plugin

Make Gradle runner resilient to local JDK and remove Foojay plugin #37

name: PR Release & Snapshot Publish
on:
pull_request:
branches:
- main
types:
- synchronize
- opened
- reopened
permissions:
contents: read
packages: write
pull-requests: write
concurrency:
group: pr-release-${{ github.event.pull_request.number }}
cancel-in-progress: false
jobs:
verify:
name: Verify
uses: ./.github/workflows/verify-version.yml
secrets: inherit
build-test-publish:
name: Build, Test & Publish Snapshot
runs-on: ubuntu-latest
needs: verify
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
steps:
- name: Checkout PR Branch
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup JDK 24 for Kotlin 2.2.0
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '24'
cache: 'gradle'
- name: Grant Execute Permission for Gradlew
run: chmod +x gradlew
- name: Build
run: ./gradlew clean copyJar --no-daemon --stacktrace
- name: Test with Kotest
run: ./gradlew kotest --stacktrace
- name: Check if publish paths changed in latest commit
id: changes
run: |
if git diff --quiet ${{ github.event.before }} ${{ github.event.after }} -- \
'modules/**/src/main/**' \
'modules/**/build.gradle' \
'build.gradle' \
'gradle.properties'; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Determine PR Snapshot Version
if: steps.changes.outputs.changed == 'true'
id: versioning
run: |
BASE_VERSION=$(grep '^baseVersion=' gradle.properties | cut -d'=' -f2)
PR_NUMBER=${{ github.event.pull_request.number }}
INCREMENT=$(date +%s)
SNAPSHOT_VERSION="${BASE_VERSION}-PR${PR_NUMBER}-${INCREMENT}-SNAPSHOT"
echo "snapshot_version=$SNAPSHOT_VERSION" >> $GITHUB_OUTPUT
echo "Using snapshot version: $SNAPSHOT_VERSION"
- name: Publish PR Snapshot to Maven Central Snapshot Repo
if: steps.changes.outputs.changed == 'true'
run: ./gradlew publishToMavenCentral -Pversion=${{ steps.versioning.outputs.snapshot_version }} --stacktrace --info
- name: Find Comment
uses: peter-evans/find-comment@v3
if: steps.changes.outputs.changed == 'true'
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- PR Snapshot Coordinates -->'
- name: Comment Snapshot Coordinates on PR
if: steps.changes.outputs.changed == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- PR Snapshot Coordinates -->
🆕 **PR Snapshot Published to Maven Central Snapshot Repository**
You can test this PR build by adding the following dependencies:
Version: `${{ steps.versioning.outputs.snapshot_version }}`
```gradle
implementation "io.github.eventhorizonlab:spi-tooling-annotations:${{ steps.versioning.outputs.snapshot_version }}"
kapt "io.github.eventhorizonlab:spi-tooling-processor:${{ steps.versioning.outputs.snapshot_version }}"
```
_This comment will be updated automatically if a new snapshot is published for this PR_
edit-mode: replace
reactions: rocket
reactions-edit-mode: replace