1+ name : PR Release & Snapshot Publish
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ types :
8+ - synchronize
9+ - opened
10+ - reopened
11+
12+ permissions :
13+ contents : read
14+ packages : write
15+ pull-requests : write
16+
17+ concurrency :
18+ group : pr-release-${{ github.event.pull_request.number }}
19+ cancel-in-progress : false
20+
21+ jobs :
22+ verify :
23+ name : Verify
24+ uses : ./.github/workflows/verify-version.yml
25+ secrets : inherit
26+
27+ build-test-publish :
28+ name : Build, Test & Publish Snapshot
29+ runs-on : ubuntu-latest
30+ needs : verify
31+ env :
32+ ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.OSSRH_USERNAME }}
33+ ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.OSSRH_PASSWORD }}
34+ ORG_GRADLE_PROJECT_signingInMemoryKey : ${{ secrets.SIGNING_KEY }}
35+ ORG_GRADLE_PROJECT_signingInMemoryKeyPassword : ${{ secrets.SIGNING_PASSWORD }}
36+
37+ steps :
38+ - name : Checkout PR Branch
39+ uses : actions/checkout@v5
40+ with :
41+ fetch-depth : 0
42+
43+ - name : Setup JDK 24 for Kotlin 2.2.0
44+ uses : actions/setup-java@v5
45+ with :
46+ distribution : ' temurin'
47+ java-version : ' 24'
48+ cache : ' gradle'
49+
50+ - name : Grant Execute Permission for Gradlew
51+ run : chmod +x gradlew
52+
53+ - name : Build
54+ run : ./gradlew clean copyJar --no-daemon --stacktrace
55+
56+ - name : Test with Kotest
57+ run : ./gradlew kotest --stacktrace
58+
59+ - name : Check if publish paths changed in latest commit
60+ id : changes
61+ run : |
62+ if git diff --quiet ${{ github.event.before }} ${{ github.event.after }} -- \
63+ 'modules/**/src/main/**' \
64+ 'modules/**/build.gradle' \
65+ 'build.gradle' \
66+ 'gradle.properties'; then
67+ echo "changed=false" >> $GITHUB_OUTPUT
68+ else
69+ echo "changed=true" >> $GITHUB_OUTPUT
70+ fi
71+
72+
73+ - name : Determine PR Snapshot Version
74+ if : steps.changes.outputs.changed == 'true'
75+ id : versioning
76+ run : |
77+ BASE_VERSION=$(grep '^baseVersion=' gradle.properties | cut -d'=' -f2)
78+ PR_NUMBER=${{ github.event.pull_request.number }}
79+ INCREMENT=$(date +%s)
80+ SNAPSHOT_VERSION="${BASE_VERSION}-PR${PR_NUMBER}-${INCREMENT}-SNAPSHOT"
81+
82+ echo "snapshot_version=$SNAPSHOT_VERSION" >> $GITHUB_OUTPUT
83+ echo "Using snapshot version: $SNAPSHOT_VERSION"
84+
85+ - name : Publish PR Snapshot to Maven Central Snapshot Repo
86+ if : steps.changes.outputs.changed == 'true'
87+ run : ./gradlew publishToMavenCentral -Pversion=${{ steps.versioning.outputs.snapshot_version }} --stacktrace --info
88+
89+ - name : Find Comment
90+ uses : peter-evans/find-comment@v3
91+ if : steps.changes.outputs.changed == 'true'
92+ id : find-comment
93+ with :
94+ issue-number : ${{ github.event.pull_request.number }}
95+ comment-author : ' github-actions[bot]'
96+ body-includes : ' <!-- PR Snapshot Coordinates -->'
97+ - name : Comment Snapshot Coordinates on PR
98+ if : steps.changes.outputs.changed == 'true'
99+ uses : peter-evans/create-or-update-comment@v4
100+ with :
101+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
102+ issue-number : ${{ github.event.pull_request.number }}
103+ body : |
104+ <!-- PR Snapshot Coordinates -->
105+ 🆕 **PR Snapshot Published to Maven Central Snapshot Repository**
106+
107+ You can test this PR build by adding the following dependencies:
108+
109+ Version: `${{ steps.versioning.outputs.snapshot_version }}`
110+
111+ ```gradle
112+ implementation "io.github.eventhorizonlab:spi-tooling-annotations:${{ steps.versioning.outputs.snapshot_version }}"
113+ kapt "io.github.eventhorizonlab:spi-tooling-processor:${{ steps.versioning.outputs.snapshot_version }}"
114+ ```
115+
116+ _This comment will be updated automatically if a new snapshot is published for this PR_
117+ edit-mode : replace
118+ reactions : rocket
119+ reactions-edit-mode : replace
0 commit comments