KMMBridgeartifactsGitHub Release Artifacts

GitHub Release Artifacts

GitHub allows you to upload binary files and attach them to a GitHub Release. This is not simply a git tag, but a GitHub-specific construct that is tied to a git tag.

KMMBridge can publish to a GitHub Release, but will require various pieces of authentication info. It is generally much easier to use our GitHub Actions workflow, as it can grab the necessary info for you.

KMMBridge GitHub Release support requires actually changing the release commit and tag after the release is created. That is because, for SPM, we need the published URL, which can only be found after uploading to an existing release. Then the Package.swift file needs that URL. To allow SPM versioning to work as expected, the release will be created, the zip file uploaded, then the Package.swift is updated and committed, and the git tag associated with the GitHub Release is updated. If you are integrating KMMBridge yourself, be aware of this.

Configuration

The Gradle plugin provides some configuration in the Gradle DSL:

kmmBridge {
    gitHubReleaseArtifacts(
        // repository: String? = null, <- The repo target. Usually the same repo. GitHub Actions can provide this automatically
        // releasString: String? = null, <- The version string. Generally provided by the Gradle version
        // useExistingRelease: Boolean = false <- Overwrite existing releases. By default, attempting to publish to an existing release will fail
    )
}

If you are using GitHub Actions and defaults, the config looks like this:

kmmBridge {
    gitHubReleaseArtifacts()
}

To actually upload the binary, we use the GitHub api, and require a bearer token. This usually comes from GitHub Actions, which provides one with authorization to modify the current repo. If you are attempting to push to a different repo, you’ll need to provide GITHUB_PUBLISH_TOKEN as a Gradle property, and it’ll need explicit access to modify the “other” repo.