Thomas Richtsfeld
12/22/2023, 8:08 AMshared-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
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:
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
kpgalligan
12/22/2023, 3:36 PMshared-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]
Thomas Richtsfeld
12/28/2023, 3:48 PMWhere is thefile 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 thePackage.swift
can’t be foundPackage.Swift
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 propertiesandgithubMail
are always null/“PLACEHOLDER”githubToken
Hard to say without seeing what you’re doing, but you can just pass in custom Gradle params when calling the workflow. ProbablyI 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(edited-PgithubMail=[whatever] -PgithubToken=[whatever]
kpgalligan
12/28/2023, 7:16 PMOur 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)
kpgalligan
12/28/2023, 7:35 PMretainBuildBranch
), but it's not super useful because you can just create a new branch with the headless commit shaThomas Richtsfeld
12/29/2023, 8:13 AMThe 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
kpgalligan
12/29/2023, 1:31 PMkpgalligan
12/29/2023, 1:32 PMPackage.swift
file for if not doing local SPM dev?Thomas Richtsfeld
12/30/2023, 10:11 AMWhat would you use the main branchSry, 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)file for if not doing local SPM dev?Package.swift