Skip to content

Commit 34084c6

Browse files
JcMinarroaleksandar-apostolovgpunto
authored
Feature/publish release workflow (#47)
* Remove old core modules * Include new core as submodule but also as a dependency * Move feeds to the new core * Update the serialization interface in core * Update core branch * Fix Filters import * Make event handlers implement FeedEventListener * Merge conflict * Add Dokka plugin * Create scripts to publish to maven * Configure Nexus Plugin * Fix namespace * Configure publish scripts * Add github action to publish a new version * Fix stream android core dependency * Remove submodule * Spotless --------- Co-authored-by: Aleksandar Apostolov <[email protected]> Co-authored-by: Gian <[email protected]>
1 parent 4232d3a commit 34084c6

File tree

7 files changed

+251
-1
lines changed

7 files changed

+251
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish New Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
type: choice
8+
description: "Type of version bump to perform"
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
14+
jobs:
15+
pre_release_check:
16+
name: Pre release check
17+
runs-on: ubuntu-24.04
18+
environment: 'publish'
19+
steps:
20+
- name: Check
21+
id: pre_release_check_step
22+
run: echo "Pre release check"
23+
publish:
24+
needs: pre_release_check
25+
uses: GetStream/android-ci-actions/.github/workflows/release-new-version.yml@main
26+
with:
27+
ref: "develop"
28+
bump: ${{ inputs.bump }}
29+
file-path: ./buildSrc/src/main/kotlin/io/getstream/feeds/android/Configuration.kt
30+
excluded-modules: "stream-feeds-android-sample"
31+
secrets:
32+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
33+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
34+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
35+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
36+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
37+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
38+
STREAM_PUBLIC_BOT_TOKEN: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import java.io.FileNotFoundException
22
import java.util.Calendar
33

4+
apply(plugin = "io.github.gradle-nexus.publish-plugin")
5+
apply(plugin = "org.jetbrains.dokka")
6+
47
apply(from = "${rootDir}/gradle/scripts/sonar.gradle")
58

69
// Top-level build file where you can add configuration options common to all sub-projects/modules.
@@ -13,6 +16,8 @@ plugins {
1316
alias(libs.plugins.arturbosch.detekt) apply true
1417
alias(libs.plugins.spotless) apply true
1518
id("com.google.gms.google-services") version "4.4.3" apply false
19+
alias(libs.plugins.dokka) apply false
20+
alias(libs.plugins.nexus) apply false
1621
alias(libs.plugins.sonarqube)
1722
alias(libs.plugins.kover)
1823
}
@@ -72,3 +77,5 @@ subprojects {
7277
}
7378
}
7479
}
80+
81+
apply(from = "${rootDir}/scripts/publish-root.gradle")

gradle/libs.versions.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ lifecycleViewModelCompose = "2.4.0"
3535
sonarqube = "6.0.1.5171"
3636
spotless = "7.2.1"
3737
turbine = "1.2.1"
38+
kotlinDokka = "1.9.20"
39+
nexusPlugin = "1.3.0"
3840

3941
[libraries]
4042
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -102,3 +104,5 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
102104
arturbosch-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
103105
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }
104106
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
107+
dokka = { id = "org.jetbrains.dokka", version.ref = "kotlinDokka" }
108+
nexus = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPlugin" }

scripts/publish-module.gradle

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
apply plugin: 'org.jetbrains.dokka'
4+
5+
tasks.register('androidSourcesJar', Jar) {
6+
archiveClassifier.set('sources')
7+
if (project.plugins.findPlugin("com.android.library")) {
8+
from android.sourceSets.main.java.srcDirs
9+
from android.sourceSets.main.kotlin.srcDirs
10+
} else {
11+
from sourceSets.main.java.srcDirs
12+
from sourceSets.main.kotlin.srcDirs
13+
}
14+
}
15+
16+
tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
17+
pluginsMapConfiguration.set(
18+
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
19+
)
20+
}
21+
22+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
23+
archiveClassifier.set('javadoc')
24+
from dokkaJavadoc.outputDirectory
25+
}
26+
27+
artifacts {
28+
archives androidSourcesJar
29+
archives javadocJar
30+
}
31+
32+
group = PUBLISH_GROUP_ID
33+
version = PUBLISH_VERSION
34+
35+
afterEvaluate {
36+
publishing {
37+
publications {
38+
release(MavenPublication) {
39+
tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("androidSourcesJar") }
40+
groupId PUBLISH_GROUP_ID
41+
artifactId PUBLISH_ARTIFACT_ID
42+
version PUBLISH_VERSION
43+
if (project.plugins.findPlugin("com.android.library")) {
44+
from components.release
45+
} else {
46+
from components.java
47+
}
48+
49+
artifact javadocJar
50+
51+
pom {
52+
name = PUBLISH_ARTIFACT_ID
53+
description = 'Stream Feeds official Android SDK'
54+
url = 'https://github.com/getstream/stream-feeds-android'
55+
licenses {
56+
license {
57+
name = 'Stream License'
58+
url = 'https://github.com/GetStream/stream-feeds-android/blob/main/LICENSE'
59+
}
60+
}
61+
developers {
62+
developer {
63+
id = 'jcminarro'
64+
name = 'Jc Miñarro'
65+
66+
}
67+
developer {
68+
id = 'aleksandar-apostolov'
69+
name = 'Aleksandar Apostolov'
70+
71+
}
72+
developer {
73+
id = 'VelikovPetar'
74+
name = 'Petar Velikov'
75+
76+
}
77+
developer {
78+
id = 'andremion'
79+
name = 'André Mion'
80+
81+
}
82+
developer {
83+
id = 'rahul-lohra'
84+
name = 'Rahul Kumar Lohra'
85+
86+
}
87+
developer {
88+
id = 'gpunto'
89+
name = 'Gianmarco'
90+
91+
}
92+
}
93+
scm {
94+
connection = 'scm:git:github.com/getstream/stream-feeds-android.git'
95+
developerConnection = 'scm:git:ssh://github.com/getstream/stream-feeds-android.git'
96+
url = 'https://github.com/getstream/stream-feeds-android/tree/main'
97+
}
98+
}
99+
}
100+
}
101+
}
102+
}
103+
104+
signing {
105+
useInMemoryPgpKeys(
106+
rootProject.ext["signing.keyId"],
107+
rootProject.ext["signing.key"],
108+
rootProject.ext["signing.password"],
109+
)
110+
sign publishing.publications
111+
}

scripts/publish-root.gradle

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import io.getstream.feeds.android.Configuration
2+
3+
// Create variables with empty default values
4+
ext["ossrhUsername"] = ''
5+
ext["ossrhPassword"] = ''
6+
ext["sonatypeStagingProfileId"] = ''
7+
ext["signing.keyId"] = ''
8+
ext["signing.password"] = ''
9+
ext["signing.key"] = ''
10+
ext["snapshot"] = ''
11+
12+
File secretPropsFile = project.rootProject.file('local.properties')
13+
if (secretPropsFile.exists()) {
14+
// Read local.properties file first if it exists
15+
Properties p = new Properties()
16+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
17+
p.each { name, value -> ext[name] = value }
18+
} else {
19+
// Use system environment variables
20+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
21+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
22+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
23+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
24+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
25+
ext["signing.key"] = System.getenv('SIGNING_KEY')
26+
ext["snapshot"] = System.getenv('SNAPSHOT')
27+
}
28+
29+
if (snapshot) {
30+
ext["rootVersionName"] = Configuration.snapshotVersionName
31+
} else {
32+
ext["rootVersionName"] = Configuration.versionName
33+
}
34+
35+
// Set up Sonatype repository
36+
nexusPublishing {
37+
repositories {
38+
sonatype {
39+
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
40+
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
41+
stagingProfileId = sonatypeStagingProfileId
42+
username = ossrhUsername
43+
password = ossrhPassword
44+
version = rootVersionName
45+
}
46+
}
47+
}
48+
49+
tasks.register("printAllArtifacts") {
50+
group = "publishing"
51+
52+
doLast {
53+
subprojects.each { subproject ->
54+
subproject.plugins.withId("maven-publish") {
55+
def publishingExtension = subproject.extensions.findByType(PublishingExtension)
56+
publishingExtension?.publications?.all { publication ->
57+
if (publication instanceof MavenPublication) {
58+
def groupId = publication.groupId
59+
def artifactId = publication.artifactId
60+
def version = publication.version
61+
println("$groupId:$artifactId:$version")
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}

stream-feeds-android-client/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ plugins {
1111
alias(libs.plugins.kover)
1212
}
1313

14+
rootProject.extra.apply {
15+
set("PUBLISH_GROUP_ID", Configuration.artifactGroup)
16+
set("PUBLISH_ARTIFACT_ID", "stream-feeds-android-client")
17+
set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName"))
18+
}
19+
20+
apply(from = "${rootDir}/scripts/publish-module.gradle")
1421
apply(from = "$rootDir/scripts/android.gradle")
1522

1623
android {
@@ -39,6 +46,10 @@ android {
3946
consumerProguardFiles("consumer-rules.pro")
4047
}
4148
}
49+
50+
publishing {
51+
singleVariant("release") { }
52+
}
4253
}
4354

4455
tasks.withType<KotlinCompile>().configureEach {

stream-feeds-android-network/build.gradle.kts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import io.getstream.feeds.android.Configuration
12
import org.gradle.kotlin.dsl.withType
23
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
34
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -7,10 +8,17 @@ plugins {
78
alias(libs.plugins.kotlin.android)
89
}
910

11+
rootProject.extra.apply {
12+
set("PUBLISH_GROUP_ID", Configuration.artifactGroup)
13+
set("PUBLISH_ARTIFACT_ID", "stream-feeds-android-network")
14+
set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName"))
15+
}
16+
17+
apply(from = "${rootDir}/scripts/publish-module.gradle")
1018
apply(from = "$rootDir/scripts/android.gradle")
1119

1220
android {
13-
namespace = "io.getstream.feeds.android.core"
21+
namespace = "io.getstream.feeds.android.network"
1422

1523
defaultConfig {
1624
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -29,6 +37,10 @@ android {
2937
consumerProguardFiles("consumer-rules.pro")
3038
}
3139
}
40+
41+
publishing {
42+
singleVariant("release") { }
43+
}
3244
}
3345

3446
tasks.withType<KotlinCompile>().configureEach {

0 commit comments

Comments
 (0)