Skip to content

Commit d42f212

Browse files
jamesarichCopilot
andcommitted
ci(build): add snapshot publishing to Maven Central on main push
After all CI jobs pass on a push to main, a new publish-snapshot job computes the next patch version with -SNAPSHOT suffix and publishes all KMP artifacts to Maven Central snapshots repository. Runs on macos-15 to cover all targets including Apple platforms. Reuses existing OSSRH and signing secrets from the release workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5591751 commit d42f212

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,38 @@ jobs:
154154

155155
- name: Build
156156
run: ./gradlew build --stacktrace
157+
158+
publish-snapshot:
159+
name: Publish Snapshot
160+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
161+
needs: [build]
162+
runs-on: macos-15
163+
steps:
164+
- uses: actions/checkout@v6
165+
with:
166+
submodules: true
167+
168+
- uses: ./.github/actions/gradle-setup
169+
with:
170+
cache_read_only: 'false'
171+
172+
- name: Compute snapshot version
173+
id: version
174+
run: |
175+
RELEASE_VERSION=$(grep '^VERSION_NAME=' gradle.properties | cut -d= -f2)
176+
IFS='.' read -r major minor patch <<< "$RELEASE_VERSION"
177+
SNAPSHOT_VERSION="${major}.${minor}.$((patch + 1))-SNAPSHOT"
178+
echo "snapshot=$SNAPSHOT_VERSION" >> "$GITHUB_OUTPUT"
179+
echo "Publishing snapshot: $SNAPSHOT_VERSION"
180+
181+
- name: Publish to Maven Central (snapshots)
182+
run: >-
183+
./gradlew publishAllPublicationsToMavenCentralRepository
184+
-PVERSION_NAME=${{ steps.version.outputs.snapshot }}
185+
--stacktrace
186+
env:
187+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
188+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
189+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
190+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
191+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

0 commit comments

Comments
 (0)