Skip to content

Commit 51c6f70

Browse files
runningcodeclaudeBYK
authored
ci: Publish snapshot builds to Maven Central (#1107)
* ci: Publish snapshot builds to Maven Central on push to main Add a `mavenCentralSnapshots` repository to both plugin-build and sentry-kotlin-compiler-plugin build files, and a new GitHub Actions workflow that publishes `-SNAPSHOT` versions on every push to main. This gives consumers early access to unreleased changes without waiting for a formal release. The snapshot flow is completely independent from the existing craft-based release process. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: Disable cancel-in-progress for snapshot publishing Cancelling a running publish can leave the Maven snapshot repository in an inconsistent state (e.g. partial artifacts or mismatched plugin versions between the Gradle Plugin and Kotlin Compiler Plugin). Queuing instead ensures each publish completes atomically. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update .github/workflows/publish-snapshot.yml Co-authored-by: Burak Yigit Kaya <byk@sentry.io> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Burak Yigit Kaya <byk@sentry.io>
1 parent 5f8168f commit 51c6f70

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: false
11+
12+
jobs:
13+
publish-snapshot:
14+
name: Publish snapshot to Maven Central
15+
runs-on: ubuntu-latest
16+
environment: production
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
20+
21+
- name: Setup Gradle
22+
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # pin@v4
23+
24+
- name: Set up Java
25+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
26+
with:
27+
distribution: 'temurin'
28+
java-version: '17'
29+
30+
- name: Determine snapshot version
31+
id: version
32+
run: |
33+
VERSION=$(grep "^version = " plugin-build/gradle.properties | cut -d' ' -f3)
34+
echo "snapshot_version=${VERSION}-SNAPSHOT" >> "$GITHUB_OUTPUT"
35+
36+
- name: Publish Gradle Plugin snapshot
37+
working-directory: plugin-build
38+
run: >
39+
../gradlew publishAllPublicationsToMavenCentralSnapshotsRepository
40+
-Pversion=${{ steps.version.outputs.snapshot_version }}
41+
env:
42+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
43+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
44+
45+
- name: Publish Kotlin Compiler Plugin snapshot
46+
working-directory: sentry-kotlin-compiler-plugin
47+
run: >
48+
../gradlew publishAllPublicationsToMavenCentralSnapshotsRepository
49+
-PVERSION_NAME=${{ steps.version.outputs.snapshot_version }}
50+
env:
51+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
52+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}

plugin-build/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,18 @@ tasks.withType<ValidatePlugins>().configureEach {
323323
failOnWarning.set(true)
324324
enableStricterValidation.set(true)
325325
}
326+
327+
plugins.withId("com.vanniktech.maven.publish.base") {
328+
configure<PublishingExtension> {
329+
repositories {
330+
maven {
331+
name = "mavenCentralSnapshots"
332+
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
333+
credentials {
334+
username = findProperty("mavenCentralUsername")?.toString()
335+
password = findProperty("mavenCentralPassword")?.toString()
336+
}
337+
}
338+
}
339+
}
340+
}

sentry-kotlin-compiler-plugin/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ plugins.withId("com.vanniktech.maven.publish.base") {
7373
name = "mavenTestRepo"
7474
url = file("${rootProject.projectDir}/../build/mavenTestRepo").toURI()
7575
}
76+
maven {
77+
name = "mavenCentralSnapshots"
78+
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
79+
credentials {
80+
username = findProperty("mavenCentralUsername")?.toString()
81+
password = findProperty("mavenCentralPassword")?.toString()
82+
}
83+
}
7684
}
7785
}
7886
}

0 commit comments

Comments
 (0)