Skip to content

Commit c67b002

Browse files
committed
ci: release pls
1 parent ea03a27 commit c67b002

File tree

8 files changed

+163
-4
lines changed

8 files changed

+163
-4
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: release please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
releases_created: ${{ steps.release.outputs.releases_created }}
17+
core_release_created: ${{ steps.release.outputs['posthog--release_created'] }}
18+
android_release_created: ${{ steps.release.outputs['posthog-android--release_created'] }}
19+
server_release_created: ${{ steps.release.outputs['posthog-server--release_created'] }}
20+
plugin_release_created: ${{ steps.release.outputs['posthog-android-gradle-plugin--release_created'] }}
21+
core_tag: ${{ steps.release.outputs['posthog--tag_name'] }}
22+
android_tag: ${{ steps.release.outputs['posthog-android--tag_name'] }}
23+
server_tag: ${{ steps.release.outputs['posthog-server--tag_name'] }}
24+
plugin_tag: ${{ steps.release.outputs['posthog-android-gradle-plugin--tag_name'] }}
25+
steps:
26+
- uses: googleapis/release-please-action@v4
27+
id: release
28+
with:
29+
config-file: release-please-config.json
30+
manifest-file: .release-please-manifest.json
31+
32+
publish-core:
33+
needs: release-please
34+
if: needs.release-please.outputs.core_release_created == 'true'
35+
runs-on: ubuntu-latest
36+
env:
37+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
38+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
39+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
40+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-java@v4
44+
with:
45+
java-version: "17"
46+
distribution: "temurin"
47+
- name: Publish Core to Maven Central
48+
run: make releaseCore
49+
50+
publish-android:
51+
needs: [release-please, publish-core]
52+
if: |
53+
always() &&
54+
needs.release-please.outputs.android_release_created == 'true' &&
55+
(needs.publish-core.result == 'success' || needs.publish-core.result == 'skipped')
56+
runs-on: ubuntu-latest
57+
env:
58+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
59+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
60+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
61+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: actions/setup-java@v4
65+
with:
66+
java-version: "17"
67+
distribution: "temurin"
68+
- name: Publish Android to Maven Central
69+
run: make releaseAndroid
70+
71+
publish-server:
72+
needs: [release-please, publish-core]
73+
if: |
74+
always() &&
75+
needs.release-please.outputs.server_release_created == 'true' &&
76+
(needs.publish-core.result == 'success' || needs.publish-core.result == 'skipped')
77+
runs-on: ubuntu-latest
78+
env:
79+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
80+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
81+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
82+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: actions/setup-java@v4
86+
with:
87+
java-version: "17"
88+
distribution: "temurin"
89+
- name: Publish Server to Maven Central
90+
run: make releaseServer
91+
92+
publish-plugin:
93+
needs: [release-please, publish-android]
94+
if: |
95+
always() &&
96+
needs.release-please.outputs.plugin_release_created == 'true' &&
97+
(needs.publish-android.result == 'success' || needs.publish-android.result == 'skipped')
98+
runs-on: ubuntu-latest
99+
env:
100+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
101+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
102+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
103+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
104+
steps:
105+
- uses: actions/checkout@v4
106+
- uses: actions/setup-java@v4
107+
with:
108+
java-version: "17"
109+
distribution: "temurin"
110+
- name: Publish Android Plugin to Maven Central
111+
run: make releaseAndroidPlugin

.release-please-manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"posthog": "5.2.0",
3+
"posthog-android": "3.27.2",
4+
"posthog-server": "2.0.1",
5+
"posthog-android-gradle-plugin": "1.0.2"
6+
}

buildSrc/src/main/java/PosthogBuildConfig.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
import groovy.json.JsonSlurper
12
import org.gradle.api.JavaVersion
3+
import java.io.File
24

35
object PosthogBuildConfig {
6+
7+
/**
8+
* Reads a module version from .release-please-manifest.json
9+
*
10+
* @param key The module key in the manifest (e.g., "posthog", "posthog-android")
11+
* @return The version string
12+
*/
13+
fun version(key: String): String {
14+
val manifestFile = File(System.getProperty("user.dir"), ".release-please-manifest.json")
15+
if (!manifestFile.exists()) {
16+
error("Release manifest not found: ${manifestFile.absolutePath}")
17+
}
18+
val versions = JsonSlurper().parseText(manifestFile.readText()) as Map<*, *>
19+
return versions[key]?.toString()
20+
?: error("Version for '$key' not found in manifest")
21+
}
422
fun shouldSkipDebugVariant(name: String): Boolean {
523
return isCI() && name == "debug"
624
}

posthog-android-gradle-plugin/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import groovy.json.JsonSlurper
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23
import java.net.URI
34

45
val postHogGroupId = "com.posthog"
56
group = postHogGroupId
6-
version = properties["androidPluginVersion"].toString()
7+
8+
val manifest = file("../.release-please-manifest.json")
9+
val versions = JsonSlurper().parseText(manifest.readText()) as Map<*, *>
10+
version = versions["posthog-android-gradle-plugin"]?.toString()
11+
?: error("Version for 'posthog-android-gradle-plugin' not found in manifest")
712

813
// Extension function for common POM configuration
914
fun MavenPom.configurePom(

posthog-android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import org.jetbrains.kotlin.config.KotlinCompilerVersion
44

5-
version = properties["androidVersion"].toString()
5+
version = PosthogBuildConfig.version("posthog-android")
66

77
plugins {
88
id("com.android.library")

posthog-server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.jetbrains.kotlin.config.KotlinCompilerVersion
44
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
55

6-
version = properties["serverVersion"].toString()
6+
version = PosthogBuildConfig.version("posthog-server")
77

88
plugins {
99
`java-library`

posthog/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.jetbrains.kotlin.config.KotlinCompilerVersion
44
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
55

6-
version = properties["coreVersion"].toString()
6+
version = PosthogBuildConfig.version("posthog")
77

88
plugins {
99
`java-library`

release-please-config.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"bootstrap-sha": "ea03a27a80e3d25c19a40e84abb35340b386892a",
4+
"release-type": "simple",
5+
"packages": {
6+
"posthog": {
7+
"component": "core"
8+
},
9+
"posthog-android": {
10+
"component": "android"
11+
},
12+
"posthog-server": {
13+
"component": "server"
14+
},
15+
"posthog-android-gradle-plugin": {
16+
"component": "androidPlugin"
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)