Skip to content

Commit

Permalink
fix gpg signing
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Sep 25, 2023
1 parent fb3a16f commit d4c747f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 30 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
matrix:
os: [ubuntu-latest]
java: ['17']
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

steps:
- name: Git checkout
Expand All @@ -38,6 +43,6 @@ jobs:
# Let's be sure that everything works before we release
- name: Dry release
run: make dryRelease

- name: Release
run: make release
# - name: Release
# run: make release
13 changes: 1 addition & 12 deletions posthog-v3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,4 @@ apiValidation {
ignoredProjects.add("posthog-android-sample")
}

nexusPublishing {
this.repositories {
sonatype {
// TODO: export env vars on GH Action
val sonatypeUsername = System.getenv("OSSRH_USERNAME")
val sonatypePassword = System.getenv("OSSRH_PASSWORD")
// stagingProfileId.set("378eecbbe2cf9")
if (sonatypeUsername != null) username.set(sonatypeUsername)
if (sonatypePassword != null) password.set(sonatypePassword)
}
}
}
nexusPublishing.postHogConfig()
25 changes: 20 additions & 5 deletions posthog-v3/buildSrc/src/main/java/PostHogPublishConfig.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import com.android.build.gradle.LibraryExtension
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.repositories
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.dokka.gradle.DokkaTask

Expand Down Expand Up @@ -99,9 +102,21 @@ fun MavenPublication.postHogConfig(projectName: String, properties: Map<String,
version = properties[PostHogPublishConfig.versionNameProperty].toString()
}

fun SigningExtension.postHogConfig(variantName: String, publishingExtension: PublishingExtension?) {
// TODO: create and test pgp key
isRequired = false
// useInMemoryPgpKeys(privateKey, password)
sign(publishingExtension?.publications?.getByName(variantName))
fun SigningExtension.postHogConfig(variantName: String, publishingExtension: PublishingExtension) {
val privateKey = System.getenv("GPG_PRIVATE_KEY")
val password = System.getenv("GPG_PASSPHRASE")
isRequired = true
useInMemoryPgpKeys(privateKey, password)
sign(publishingExtension.publications.getByName(variantName))
}

fun NexusPublishExtension.postHogConfig() {
repositories {
sonatype {
val sonatypeUsername = System.getenv("OSSRH_USERNAME")
val sonatypePassword = System.getenv("OSSRH_PASSWORD")
if (sonatypeUsername != null) username.set(sonatypeUsername)
if (sonatypePassword != null) password.set(sonatypePassword)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal class PostHogAppInstallIntegration(private val context: Context, privat

// TODO: do we need to send an event every time as an update? we need to compare the Ids maybe?
// maybe it didnt change
// fix me
PostHog.capture(event, properties = props)
}
}
Expand Down
3 changes: 1 addition & 2 deletions posthog-v3/posthog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ publishing {
pom.postHogConfig(project.name)
}
}
signing.postHogConfig("maven", this)
}

signing.postHogConfig("maven", publishing)

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = PosthogBuildConfig.Build.JAVA_VERSION.toString()
kotlinOptions.languageVersion = PosthogBuildConfig.Kotlin.KOTLIN_COMPATIBILITY
Expand Down
1 change: 1 addition & 0 deletions posthog-v3/posthog/src/main/java/com/posthog/PostHog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,4 @@ public class PostHog private constructor() {
}

// TODO: question about persisted properties, do we cache within the same session?
// fixme: it should only do that when registering and unregistering is called
6 changes: 2 additions & 4 deletions posthog-v3/posthog/src/main/java/com/posthog/PostHogConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class PostHogConfig(
public var sendFeatureFlagEvent: Boolean = true,
public var preloadFeatureFlags: Boolean = true,
// min. allowed is 1
public var flushAt: Int = 20,
public var flushAt: Int = 20, // TODO: remove this one
public var maxQueueSize: Int = 1000,
public var maxBatchSize: Int = 10,
public var maxBatchSize: Int = 50,
// (30).toDuration(DurationUnit.SECONDS) requires Kotlin 1.6
public var flushIntervalSeconds: Int = 30,

Expand All @@ -36,8 +36,6 @@ public class PostHogConfig(

internal val userAgent: String = "$sdkName/$sdkVersion"

// TODO: should this be configurable by the user?
// should we allow in memory cache only?
@PostHogInternal
public var legacyStoragePrefix: String? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import java.util.concurrent.atomic.AtomicBoolean

internal class PostHogFeatureFlags(private val config: PostHogConfig, private val api: PostHogApi) {
// TODO: do we need the onFeatureFlags callback?
// fix me, yes, maybe a sync method is better UX

// TODO: do we need Overriding server properties?
// https://posthog.com/docs/libraries/js#overriding-server-properties

// TODO: Early access feature?
private val executor = Executors.newSingleThreadScheduledExecutor(PostHogThreadFactory("PostHogDecideThread"))

private var isLoadingFeatureFlags = AtomicBoolean(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ internal class PostHogQueue(private val config: PostHogConfig, private val api:
} catch (e: PostHogApiError) {
if (e.statusCode >= 400) {
// TODO: the reason to delete or not the files?
// make it as ph-js, drop if its 4xx
}
throw e
} catch (e: IOException) {
Expand Down

0 comments on commit d4c747f

Please sign in to comment.