Skip to content

ci(kotlin): publish on the push of a release commit to main - #1745

Draft
mattcreaser wants to merge 1 commit into
mainfrom
mattcreaser/kotlin-publish-push-trigger
Draft

mattcreaser wants to merge 1 commit into
mainfrom
mattcreaser/kotlin-publish-push-trigger

Conversation

@mattcreaser

Copy link
Copy Markdown
Contributor

Problem

The Kotlin Maven Central publish is triggered by pull_request: [closed], so the
publish job deploys from refs/pull/<n>/merge. That ref is not a branch, so it
satisfies no deployment branch policy on the publish-maven environment and the
deployment is rejected before the job starts:

Branch "refs/pull/1698/merge" is not allowed to deploy to publish-maven due to
environment protection rules.

This cannot be fixed from the environment side: branch policies match branch
names, and a PR merge ref is not a branch. Seen on the 1.0.0 release
(run), where build
succeeded and publish was rejected.

Change

Trigger on the push of the release commit to main rather than on the merge of
the release PR. A push deploys from refs/heads/main, which the existing main
branch policy already allows, so the environment needs no change. This also
matches how publish-packages.yml is triggered.

The push is filtered to native/kotlin/gradle.properties, the file the release
PR bumps. Because other changes touch that file too, a new gate job resolves
VERSION_NAME and stops the run when kotlin@<version> is already tagged, so
an unrelated push never re-uploads a published release. The same check makes a
repeated workflow_dispatch a no-op rather than a failed Central upload.

workflow_dispatch still works and is still restricted to main. The
dry_run input, the credential handling, the signing steps and the release
job are unchanged.

Testing

Not directly exercisable before merge — the trigger only fires on a push to
main. Verified that the YAML parses and that the job graph is
gate -> build -> publish -> release, with build gated on
needs.gate.outputs.publish. The next release exercises the real path; a
workflow_dispatch against main exercises everything except the push trigger
itself.

A pull_request run deploys from refs/pull/<n>/merge. That is not a branch,
so it matches no deployment branch policy on the publish-maven environment
and the publish job is rejected before it starts. Trigger on the push to
main instead, which deploys from refs/heads/main.

Add a gate job that skips a version already carrying its release tag, so
pushes that touch native/kotlin/gradle.properties without bumping the
version, and repeated manual dispatches, do not try to republish.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant