Hey everyone and merry Christmas upfront :christma...
# touchlab-tools
t
Hey everyone and merry Christmas upfront 🎄 I have a few questions about KMMBridge 1. Where does KMMBridge derive the artifact name from? Our name always ends up with
shared-kmmbridge
(see screenshot) 2. How is it possible to set a custom version? It seems like the GHA always uses autoversioning and I didn’t find a way to disable it and use a random version 3. Could you explain what
addGithubPackagesRepository()
is doing? 4. Where is the
Package.swift
file after running the GHA? The tag and the packages are created, but as soon as I want to add the repo to xCode it fails because the
Package.Swift
can’t be found 5. I am trying to publish the packages to a different repo, than the GHA is running in. I am using the following code for that. Unfortunately I can’t pass the secrets down from the GHA to gradle. The properties
githubMail
and
githubToken
are always null/“PLACEHOLDER” Kotlin/Gradle
Copy code
val PLACEHOLDER = "PLACEHOLDER"

fun fromPropertyOrEnv(name: String): String =
    findProperty(name)?.toString() ?: gradleLocalProperties(rootDir).getProperty(name) ?: System.getenv(name)
    ?: PLACEHOLDER

val githubMail: String = fromPropertyOrEnv("gitHubUserName")
val githubToken: String = fromPropertyOrEnv("gitHubAccessToken")

publishing {
    repositories {
        maven {
            url = uri("<https://maven.pkg.github.com/company/repo>")
            credentials {
                username = githubMail
                password = githubToken
            }
        }
    }
}
GHA:
Copy code
env:
  gitHubUserName: ${{ secrets.GH_USER_NAME }}
  gitHubAccessToken: ${{ secrets.GH_ACCESS_TOKEN }}

jobs:
  publishIOs:
    permissions:
      contents: write
      packages: write
    uses: touchlab/KMMBridgeGithubWorkflow/.github/workflows/faktorybuildautoversion.yml@v1.1
    with:
      jvmVersion: 17
      versionBaseProperty: LIBRARY_VERSION
      module: shared
    secrets: inherit
k
> Where does KMMBridge derive the artifact name from? Our name always ends up with
shared-kmmbridge
(see screenshot) https://github.com/touchlab/KMMBridge/blob/f48be0f8b1eafb118ec60c0aaaf3deea0d43ad4[…]touchlab/faktory/artifactmanager/MavenPublishArtifactManager.kt
shared
is the Gradle name of the module.
kmmbridge
is hard-coded. The name has no real config options because it's just using maven as a place to put the zip file. You can control the framework name elsewhere, but that won't impact the artifact name. What's the use case here? Are you not using SPM or CocoaPods? > How is it possible to set a custom version? It seems like the GHA always uses autoversioning and I didn’t find a way to disable it and use a random version You'd need to write a different GHA workflow. That workflow is intended to be for a specific case, which is automatically incrementing build version numbers. To have a "custom" version, you could copy the workflow script, pass in a version param (or have it in a Gradle property), then remove the autoversion parts (essentially). > Could you explain what
addGithubPackagesRepository()
is doing? https://github.com/touchlab/KMMBridge/blob/13a5b9d21c31a8e7d0ee6b5aaeb2971e56ba3c23/kmmbridge/src/main/kotlin/BuildFileHelper.kt#L21 A "helper" function specific to the GHA workflow. Adds the GitHub Packages maven repo to the Gradle publishing plugin. It gets the repo and GitHub token secret from properties passed in by the GHA workflow. Without this, you would need a block defining the maven repo you want to publish to (see docs) > Where is the
Package.swift
file after running the GHA? The tag and the packages are created, but as soon as I want to add the repo to xCode it fails because the
Package.Swift
can’t be found It should be in the repo root folder. Hard to say what's going on in your case without more info. Did you use the template? > I am trying to publish the packages to a different repo, than the GHA is running in. I am using the following code for that. Unfortunately I can’t pass the secrets down from the GHA to gradle. The properties
githubMail
and
githubToken
are always null/“PLACEHOLDER” Hard to say without seeing what you're doing, but you can just pass in custom Gradle params when calling the workflow. Probably
-PgithubMail=[whatever] -PgithubToken=[whatever]
t
1. We are using SPM. There is “no” use case. I was just wondering how it is possible to change the name. I checked the template project and it contained artifacts without the hardcoded name ✅ 2. Alright. I was not aware that this GHA is so specific to the use case. I thought that is what everyone should use with KMMBridge ✅ 3. ✅ 4.
Where is the
Package.swift
file after running the GHA? The tag and the packages are created, but as soon as I want to add the repo to xCode it fails because the
Package.Swift
can’t be found
It should be in the repo root folder. Hard to say what’s going on in your case without more info. Did you use the template?
No we just applied everything to our use case. As said, the GHA runs through normally and the tags are created. Nothing is failing. Our repo is protected though. No one is allowed to push to the main branch without a pull request. Could that be the issue. But on the other hand something should fail no? 5.
I am trying to publish the packages to a different repo, than the GHA is running in. I am using the following code for that. Unfortunately I can’t pass the secrets down from the GHA to gradle. The properties
githubMail
and
githubToken
are always null/“PLACEHOLDER”
Hard to say without seeing what you’re doing, but you can just pass in custom Gradle params when calling the workflow. Probably
-PgithubMail=[whatever] -PgithubToken=[whatever]
(edited
I can give the gradle custom params a try. What we are doing is just what you can see in the attached source code. More or less the same thing as in the template + running the GHA workflow to publish iOS
k
Our repo is protected though. No one is allowed to push to the main branch without a pull request. Could that be the issue. But on the other hand something should fail no?
The GA workflow creates a branch for the build. It shouldn't be pushing to main. If you look at the version tags, open the source at that commit. It's "headless" because the build branch is deleted, but the commit is still there. You can get to the code, but it won't clutter up your main branch history. Example screenshots attached (See release from the template: https://github.com/touchlab/KMMBridgeSKIETemplate/commit/318cd25d69155064927f436c6633152af4bc6184)
đź’ˇ 1
The workflow gives an option to not delete the build branch when the build is done (
retainBuildBranch
), but it's not super useful because you can just create a new branch with the headless commit sha
t
The GA workflow creates a branch for the build. It shouldn’t be pushing to main. If you look at the version tags, open the source at that commit. It’s “headless” because the build branch is deleted, but the commit is still there. You can get to the code, but it won’t clutter up your main branch history. Example screenshots attached (See release from the template: https://github.com/touchlab/KMMBridgeSKIETemplate/commit/318cd25d69155064927f436c6633152af4bc6184)
Are you saying that it requires a manual step to push the Package.swift file to the main branch? If that is the case it was not obvious from the documentation
k
Well, it's a bit deep into the docs, but it does talk about it: https://kmmbridge.touchlab.co/docs/spm/IOS_LOCAL_DEV_SPM
What would you use the main branch
Package.swift
file for if not doing local SPM dev?
t
What would you use the main branch
Package.swift
file for if not doing local SPM dev?
Sry, I think I missed that in my initial comment. Our Android and KMP code is in this repo where I was talking about the main branch. The iOS code is in a different repo. My main goal is to use the released binaries in the iOS repo (non local dev flow)