Skip to content

Commit 5fc4a26

Browse files
authored
Migrate to vanniktech maven publish (#2300)
1 parent 9f8c1de commit 5fc4a26

File tree

10 files changed

+138
-314
lines changed

10 files changed

+138
-314
lines changed

.github/workflows/publish-api-docs.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish API Docs to GitHub Pages
1+
name: Publish API docs and record SDK version
22

33
on:
44
workflow_call:
@@ -20,6 +20,16 @@ jobs:
2020
runs-on: ubuntu-latest
2121
timeout-minutes: 60
2222
steps:
23+
- name: Validate access to version data service
24+
uses: embrace-io/public-actions/upload-sdk-version@88167cd1a3fce3418e26c8c842026e6dfab99e41
25+
with:
26+
platform: 'android'
27+
version: ${{ inputs.rc_version }}
28+
dryRun: true
29+
uploadUrl: ${{ vars.SDK_VERSION_URL }}
30+
env:
31+
SDK_VERSION_TOKEN: ${{ secrets.SDK_VERSION_TOKEN }}
32+
2333
- name: Configure git
2434
run: |
2535
git config --global user.name 'embrace-ci[bot]'
@@ -60,3 +70,13 @@ jobs:
6070
git config --global user.email "embrace-ci@users.noreply.github.com"
6171
git commit --allow-empty --message "CI/CD: Automatically generated documentation for ${RC_VERSION}" docs/
6272
git push --force origin gh-pages
73+
74+
- name: Record SDK Version History
75+
uses: embrace-io/public-actions/upload-sdk-version@88167cd1a3fce3418e26c8c842026e6dfab99e41
76+
with:
77+
platform: 'android'
78+
version: ${{ inputs.rc_version }}
79+
dryRun: false
80+
uploadUrl: ${{ vars.SDK_VERSION_URL }}
81+
env:
82+
SDK_VERSION_TOKEN: ${{ secrets.SDK_VERSION_TOKEN }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish snapshot
2+
3+
env:
4+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_TOKEN_USER }}
5+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_TOKEN_USER_PASSWORD }}
6+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MAVEN_ANDROID_SIGNING_KEY }}
7+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_ANDROID_GPG_KEY }}
8+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_ANDROID_SIGNING_PASSWORD }}
9+
10+
on:
11+
schedule:
12+
- cron: '0 5 * * *' # Runs every day at 5:00 UTC
13+
workflow_dispatch:
14+
inputs:
15+
snapshot_name:
16+
description: 'Name of the snapshot to be published. -SNAPSHOT will be appended automatically, so just add a name. e.g. 7.7.0'
17+
required: false
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
release:
24+
timeout-minutes: 60
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Set snapshot_name in gradle.properties if set
28+
env:
29+
SNAPSHOT_NAME: ${{ inputs.snapshot_name }}
30+
run: |
31+
if [ -n "$SNAPSHOT_NAME" ]; then
32+
sed -i -r "s#^version=.*#version=${SNAPSHOT_NAME}-SNAPSHOT#" gradle.properties
33+
git add gradle.properties
34+
fi
35+
36+
- name: Fail if version is not -SNAPSHOT
37+
run: |
38+
grep -q -- '-SNAPSHOT$' gradle.properties || (echo "ERROR: version must end with -SNAPSHOT" && exit 1)
39+
40+
- name: Setup Java
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: 'adopt'
44+
java-version: 17
45+
46+
- name: Setup Gradle
47+
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
48+
49+
- name: Publish to Maven Central
50+
run: |
51+
./gradlew publishToMavenCentral --no-configuration-cache --stacktrace
Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +0,0 @@
1-
name: Release RC and Update Docs
2-
3-
env:
4-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_TOKEN_USER }}
5-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_TOKEN_USER_PASSWORD }}
6-
MAVEN_QA_USER: github
7-
MAVEN_QA_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
8-
mavenSigningKeyId: ${{ secrets.MAVEN_ANDROID_SIGNING_KEY }}
9-
mavenSigningKeyRingFileEncoded: ${{ secrets.MAVEN_ANDROID_GPG_KEY }}
10-
mavenSigningKeyPassword: ${{ secrets.MAVEN_ANDROID_SIGNING_PASSWORD }}
11-
12-
on:
13-
workflow_dispatch:
14-
inputs:
15-
rc_version:
16-
description: 'SDK version this workflow run will release. Specify <major.minor.patch> e.g. 7.1.2. It will use the branch "release/<version>".'
17-
required: true
18-
19-
permissions:
20-
contents: read
21-
22-
jobs:
23-
release-to-maven-central:
24-
runs-on: ubuntu-latest
25-
timeout-minutes: 60
26-
steps:
27-
- name: Validate access to version data service
28-
uses: embrace-io/public-actions/upload-sdk-version@88167cd1a3fce3418e26c8c842026e6dfab99e41
29-
with:
30-
platform: 'android'
31-
version: ${{ inputs.rc_version }}
32-
dryRun: true
33-
uploadUrl: ${{ vars.SDK_VERSION_URL }}
34-
env:
35-
SDK_VERSION_TOKEN: ${{ secrets.SDK_VERSION_TOKEN }}
36-
37-
- name: Checkout SDK
38-
uses: actions/checkout@v4
39-
with:
40-
ref: release/${{ inputs.rc_version }}
41-
fetch-depth: 0
42-
persist-credentials: false
43-
44-
- name: Setup Java
45-
uses: actions/setup-java@v4
46-
with:
47-
distribution: 'adopt'
48-
java-version: 17
49-
50-
- name: Setup Gradle
51-
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
52-
53-
- name: Release to Maven Central
54-
run: |
55-
./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository -Dorg.gradle.parallel=false --no-build-cache --no-configuration-cache --stacktrace
56-
57-
- name: Record SDK Version History
58-
uses: embrace-io/public-actions/upload-sdk-version@88167cd1a3fce3418e26c8c842026e6dfab99e41
59-
with:
60-
platform: 'android'
61-
version: ${{ inputs.rc_version }}
62-
dryRun: false
63-
uploadUrl: ${{ vars.SDK_VERSION_URL }}
64-
env:
65-
SDK_VERSION_TOKEN: ${{ secrets.SDK_VERSION_TOKEN }}
66-
67-
publish-api-docs:
68-
name: Publish API Docs to GitHub Pages
69-
uses: ./.github/workflows/publish-api-docs.yml
70-
secrets: inherit
71-
permissions:
72-
contents: write
73-
with:
74-
rc_version: ${{ inputs.rc_version }}

.github/workflows/upload-artifacts-to-sonatype.yml renamed to .github/workflows/upload-artifacts-to-maven-central.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
name: Upload artifacts to Sonatype
1+
name: Upload artifacts to Maven Central
22

33
env:
4-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_TOKEN_USER }}
5-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_TOKEN_USER_PASSWORD }}
6-
MAVEN_QA_USER: github
7-
MAVEN_QA_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
8-
mavenSigningKeyId: ${{ secrets.MAVEN_ANDROID_SIGNING_KEY }}
9-
mavenSigningKeyRingFileEncoded: ${{ secrets.MAVEN_ANDROID_GPG_KEY }}
10-
mavenSigningKeyPassword: ${{ secrets.MAVEN_ANDROID_SIGNING_PASSWORD }}
4+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_TOKEN_USER }}
5+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_TOKEN_USER_PASSWORD }}
6+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MAVEN_ANDROID_SIGNING_KEY }}
7+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_ANDROID_GPG_KEY }}
8+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_ANDROID_SIGNING_PASSWORD }}
119

1210
on:
1311
workflow_call:
@@ -29,12 +27,6 @@ jobs:
2927
timeout-minutes: 60
3028
runs-on: ubuntu-latest
3129
steps:
32-
- name: Decode Keystore
33-
run: |
34-
mkdir "$RUNNER_TEMP"/keystore
35-
echo $mavenSigningKeyRingFileEncoded | base64 -di > "$RUNNER_TEMP"/keystore/2DE631C1.gpg
36-
echo "mavenSigningKeyRingFile=$RUNNER_TEMP/keystore/2DE631C1.gpg" >> $GITHUB_ENV
37-
3830
- name: Configure git
3931
run: |
4032
git config --global user.name 'embrace-ci[bot]'
@@ -55,9 +47,9 @@ jobs:
5547
- name: Setup Gradle
5648
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
5749

58-
- name: Publish and close Sonatype repository
50+
- name: Publish to Maven Central
5951
run: |
60-
./gradlew publishAllPublicationsToSonatypeRepository -x embrace-gradle-plugin-integration-tests:publishAllPublicationsToSonatypeRepository closeSonatypeStagingRepository -Dorg.gradle.parallel=false --no-build-cache --no-configuration-cache --stacktrace
52+
./gradlew publishToMavenCentral --no-configuration-cache --stacktrace
6153
6254
- name: Publish git tag
6355
env:

build.gradle.kts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
1-
import java.time.Duration
21
import org.jetbrains.dokka.gradle.DokkaTaskPartial
32

43
plugins {
54
kotlin("android") apply false
65
kotlin("jvm") apply false
76
alias(libs.plugins.google.ksp) apply false
87
id("com.android.library") apply false
9-
alias(libs.plugins.nexus.publish)
108
alias(libs.plugins.dokka)
119
alias(libs.plugins.kover)
1210
}
1311

1412
group = "io.embrace"
1513
version = project.version
1614

17-
nexusPublishing {
18-
repositories {
19-
sonatype {
20-
username = System.getenv("SONATYPE_USERNAME")
21-
password = System.getenv("SONATYPE_PASSWORD")
22-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
23-
}
24-
}
25-
transitionCheckOptions {
26-
maxRetries.set(60)
27-
delayBetween.set(Duration.ofSeconds(20))
28-
}
29-
connectTimeout.set(Duration.ofMinutes(15))
30-
clientTimeout.set(Duration.ofMinutes(15))
31-
}
32-
3315
subprojects {
3416
if (project.name == "embrace-android-sdk" || project.name == "embrace-android-api") {
3517
apply(plugin = "org.jetbrains.dokka")

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies {
1919
implementation(libs.agp)
2020
implementation(libs.detekt.gradle.plugin)
2121
implementation(libs.binary.compatibility.validator)
22+
implementation(libs.vanniktech.maven.publish)
2223
}
2324

2425
gradlePlugin {

buildSrc/src/main/kotlin/io/embrace/internal/ProductionModuleConfig.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import org.gradle.kotlin.dsl.getByType
77

88
fun Project.configureProductionModule(
99
android: LibraryExtension,
10-
module: EmbraceBuildLogicExtension
10+
module: EmbraceBuildLogicExtension,
1111
) {
1212
with(project.pluginManager) {
1313
apply("checkstyle")
1414
apply("org.jetbrains.kotlinx.kover")
15-
apply("maven-publish")
16-
apply("signing")
15+
apply("com.vanniktech.maven.publish")
1716
apply("binary-compatibility-validator")
1817
}
1918

@@ -37,16 +36,6 @@ fun Project.configureProductionModule(
3736
}
3837
}
3938

40-
publishing {
41-
42-
// create component with single publication variant
43-
// https://developer.android.com/studio/publish-library/configure-pub-variants#single-pub-var
44-
singleVariant("release") {
45-
withSourcesJar()
46-
withJavadocJar()
47-
}
48-
}
49-
5039
sourceSets {
5140
getByName("test").java.srcDir("src/integrationTest/java")
5241
getByName("test").kotlin.srcDir("src/integrationTest/kotlin")

0 commit comments

Comments
 (0)