From 1c03f443b73fbc0de015913230abc5419b37df42 Mon Sep 17 00:00:00 2001 From: Kanat Date: Thu, 19 Nov 2026 10:45:01 +0100 Subject: [PATCH 1/4] ci(kotlin): publish a release only from the merge of a release-kotlin PR A push to main published whenever gradle.properties held a new non-SNAPSHOT version. It now asks the API for the pull request that the pushed commit merged, and publishes only when its head is release-kotlin-X.Y.Z. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/publish-sdk-kotlin.yml | 25 ++++++++++++++++++------ sdks/kotlin/README.md | 3 ++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-sdk-kotlin.yml b/.github/workflows/publish-sdk-kotlin.yml index 8bc6115f0..c15de56bf 100644 --- a/.github/workflows/publish-sdk-kotlin.yml +++ b/.github/workflows/publish-sdk-kotlin.yml @@ -9,7 +9,8 @@ name: Publish Kotlin SDK # - A pull request from release-kotlin-X.Y.Z (version=X.Y.Z) fails unless X.Y.Z is newer than the # last `sdk-kotlin-v*` tag and not already published. Merging it into main publishes the # release, then tags the commit `sdk-kotlin-vX.Y.Z`. -# - Any other push to main publishes nothing, and other pull requests do not run the jobs. +# - Any other push to main publishes nothing, even one that sets a new version: only the merge of +# a pull request from release-kotlin-X.Y.Z does. Other pull requests do not run the jobs. # # There is no GitHub release: publishing one starts the Python release (release.yml), and the # repository's releases are the Python packages'. @@ -38,6 +39,9 @@ jobs: # Of the pull requests, only a release's: one from a branch named release-kotlin-X.Y.Z. if: github.event_name == 'push' || startsWith(github.head_ref, 'release-kotlin-') runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read # the pull request a push to main merged outputs: version: ${{ steps.version.outputs.version }} channel: ${{ steps.version.outputs.channel }} @@ -52,8 +56,21 @@ jobs: id: version env: BRANCH: ${{ github.head_ref || github.ref_name }} + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail + # A push to main is a release only as the merge of a pull request from release-kotlin-X.Y.Z. + if [ "$GITHUB_EVENT_NAME" = push ] && [ "$BRANCH" = main ]; then + heads=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" \ + --jq '.[] | select(.base.ref == "main" and .merged_at != null) | .head.ref') + release=$(grep -xE 'release-kotlin-[0-9]+\.[0-9]+\.[0-9]+' <<< "$heads" | head -1 || true) + if [ -z "$release" ]; then + echo "::notice::Nothing is published: this push is not the merge of a release-kotlin-X.Y.Z pull request." + echo "channel=none" >> "$GITHUB_OUTPUT" + exit 0 + fi + BRANCH="$release" + fi version=$(sed -n 's/^version=//p' sdks/kotlin/gradle.properties) if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$ ]]; then echo "::error file=sdks/kotlin/gradle.properties::version=$version is not X.Y.Z or X.Y.Z-SNAPSHOT"; exit 1 @@ -63,11 +80,7 @@ jobs: echo "::error file=sdks/kotlin/gradle.properties::$BRANCH publishes ${BASH_REMATCH[1]}, but version=$version"; exit 1 fi last=$(git tag -l 'sdk-kotlin-v*' | sed 's/^sdk-kotlin-v//' | sort -V | tail -1) - if [ "$BRANCH" = main ] && { [[ "$version" == *-SNAPSHOT ]] || [ "$version" = "$last" ]; }; then - # Not a release: snapshots are published from release-kotlin-X.Y.Z-SNAPSHOT only. - echo "channel=none" >> "$GITHUB_OUTPUT" - exit 0 - elif [[ "$version" == *-SNAPSHOT ]]; then + if [[ "$version" == *-SNAPSHOT ]]; then # A snapshot of X.Y.Z sorts below release X.Y.Z, so X.Y.Z must be one still to come. base="${version%-SNAPSHOT}" if [ -n "$last" ] && { [ "$base" = "$last" ] || [ "$(printf '%s\n%s\n' "$last" "$base" | sort -V | tail -1)" != "$base" ]; }; then diff --git a/sdks/kotlin/README.md b/sdks/kotlin/README.md index 7e3a92371..9661295a0 100644 --- a/sdks/kotlin/README.md +++ b/sdks/kotlin/README.md @@ -382,6 +382,7 @@ to `https://stream-io-repo.com` from `release-kotlin-*` branches only. `version` `version=X.Y.Z`. It fails unless `X.Y.Z` is newer than the last release and not already published. Merging it publishes the release and tags the commit `sdk-kotlin-vX.Y.Z`. -Other merges into `main` publish nothing. +Other merges into `main` publish nothing, even one that sets a new `version`: only the merge of a +pull request from a `release-kotlin-X.Y.Z` branch publishes. There is no GitHub release: publishing one starts the Python release, `release.yml`. From 7c35b15344f8034b3b16a021a38cbec0afac9ff0 Mon Sep 17 00:00:00 2001 From: Kanat Date: Thu, 19 Nov 2026 10:54:49 +0100 Subject: [PATCH 2/4] AI-3368: say how to re-run a release merge whose lookup lagged A release merge's run can find no pull request (the API lags right after the merge), and then publishes nothing. Re-running all its jobs recovers it. Say so in the workflow header, the README and the notice. Co-Authored-By: Claude Haiku 5.5 --- .github/workflows/publish-sdk-kotlin.yml | 4 +++- sdks/kotlin/README.md | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-sdk-kotlin.yml b/.github/workflows/publish-sdk-kotlin.yml index c15de56bf..9d541d359 100644 --- a/.github/workflows/publish-sdk-kotlin.yml +++ b/.github/workflows/publish-sdk-kotlin.yml @@ -11,6 +11,8 @@ name: Publish Kotlin SDK # release, then tags the commit `sdk-kotlin-vX.Y.Z`. # - Any other push to main publishes nothing, even one that sets a new version: only the merge of # a pull request from release-kotlin-X.Y.Z does. Other pull requests do not run the jobs. +# If the run of a release merge says nothing is published, re-run all its jobs: the lookup of +# its pull request can lag right after the merge. # # There is no GitHub release: publishing one starts the Python release (release.yml), and the # repository's releases are the Python packages'. @@ -65,7 +67,7 @@ jobs: --jq '.[] | select(.base.ref == "main" and .merged_at != null) | .head.ref') release=$(grep -xE 'release-kotlin-[0-9]+\.[0-9]+\.[0-9]+' <<< "$heads" | head -1 || true) if [ -z "$release" ]; then - echo "::notice::Nothing is published: this push is not the merge of a release-kotlin-X.Y.Z pull request." + echo "::notice::Nothing is published: this push is not the merge of a release-kotlin-X.Y.Z pull request. If it is one, the lookup may have lagged: re-run all jobs of this run." echo "channel=none" >> "$GITHUB_OUTPUT" exit 0 fi diff --git a/sdks/kotlin/README.md b/sdks/kotlin/README.md index 9661295a0..a49eb9044 100644 --- a/sdks/kotlin/README.md +++ b/sdks/kotlin/README.md @@ -383,6 +383,7 @@ to `https://stream-io-repo.com` from `release-kotlin-*` branches only. `version` published. Merging it publishes the release and tags the commit `sdk-kotlin-vX.Y.Z`. Other merges into `main` publish nothing, even one that sets a new `version`: only the merge of a -pull request from a `release-kotlin-X.Y.Z` branch publishes. +pull request from a `release-kotlin-X.Y.Z` branch publishes. If a release merge's run says nothing +is published, re-run all its jobs: the lookup of its pull request can lag right after the merge. There is no GitHub release: publishing one starts the Python release, `release.yml`. From 976c5d9f19c7ecf3255e9130479bd142432092cb Mon Sep 17 00:00:00 2001 From: Kanat Date: Thu, 19 Nov 2026 10:54:54 +0100 Subject: [PATCH 3/4] AI-3368: name the org secrets the release environment does not limit The workflow comments said the signing key and the repository endpoint live in the release environment. They are GetStream organization secrets, which the environment does not limit; moving them into it is AI-3372. Co-Authored-By: Claude Haiku 5.5 --- .github/workflows/publish-sdk-kotlin.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-sdk-kotlin.yml b/.github/workflows/publish-sdk-kotlin.yml index 9d541d359..074a42374 100644 --- a/.github/workflows/publish-sdk-kotlin.yml +++ b/.github/workflows/publish-sdk-kotlin.yml @@ -115,7 +115,8 @@ jobs: needs: version if: github.event_name == 'push' && needs.version.outputs.channel != 'none' runs-on: ubuntu-latest - # The signing key lives in this environment, which only the publishing branches may enter. + # The signing key is a GetStream organization secret: this environment does not limit it, and any + # workflow in this repository can read it. Moving it into `release` is AI-3372. environment: release defaults: run: @@ -170,7 +171,8 @@ jobs: name: Upload to the Stream repository needs: [ version, publish ] runs-on: ubuntu-latest - # The repository endpoint and bucket live in this environment, as the signing key does. + # The repository endpoint, bucket and credentials are GetStream organization secrets too: this + # environment does not limit them either (AI-3372 moves them into `release`). environment: release permissions: contents: write # the sdk-kotlin-v* tag of a release From 3655443b305adfae00ce2976a412e267d6c97b48 Mon Sep 17 00:00:00 2001 From: Kanat Date: Thu, 19 Nov 2026 10:58:04 +0100 Subject: [PATCH 4/4] AI-3368: say AI-3372 tracks limiting the release secrets, not moves them Co-Authored-By: Claude Haiku 5.5 --- .github/workflows/publish-sdk-kotlin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-sdk-kotlin.yml b/.github/workflows/publish-sdk-kotlin.yml index 074a42374..4959a8762 100644 --- a/.github/workflows/publish-sdk-kotlin.yml +++ b/.github/workflows/publish-sdk-kotlin.yml @@ -116,7 +116,7 @@ jobs: if: github.event_name == 'push' && needs.version.outputs.channel != 'none' runs-on: ubuntu-latest # The signing key is a GetStream organization secret: this environment does not limit it, and any - # workflow in this repository can read it. Moving it into `release` is AI-3372. + # workflow in this repository can read it. AI-3372 tracks limiting it to the release jobs. environment: release defaults: run: @@ -172,7 +172,7 @@ jobs: needs: [ version, publish ] runs-on: ubuntu-latest # The repository endpoint, bucket and credentials are GetStream organization secrets too: this - # environment does not limit them either (AI-3372 moves them into `release`). + # environment does not limit them either. AI-3372 tracks limiting them to the release jobs. environment: release permissions: contents: write # the sdk-kotlin-v* tag of a release