From a9cf1229ce9ab826d93348351ca132a446af2311 Mon Sep 17 00:00:00 2001 From: liammclennan-ro Date: Tue, 24 Nov 2026 11:26:14 +1000 Subject: [PATCH 1/3] Manually publish dev builds. --- .github/workflows/publish.yml | 91 ++++++++++++++++++++++++++--------- build/README.md | 8 ++- 2 files changed, 73 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1e9b6548..557f33f6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,8 @@ -# Publishes the packages built by a successful CI run to NuGet.org and npm +# Publishes the packages built by a successful CI run to NuGet.org and npm. +# +# CI runs on `main` are published automatically. Builds from other branches (e.g. `dev`) are only +# published when this workflow is run manually from the Actions tab, selecting the branch to publish; +# that publishes the latest successful CI push build of the branch. name: Publish @@ -6,27 +10,65 @@ on: workflow_run: workflows: [ "CI" ] types: [ completed ] - branches: [ "dev", "main" ] + branches: [ "main" ] + workflow_dispatch: permissions: {} -env: - # Reproduce the version computed by the triggering CI run (see Get-SemVer in build/Build.Common.ps1). - CI_BUILD_NUMBER_BASE: ${{ github.event.workflow_run.run_number }} - CI_TARGET_BRANCH: ${{ github.event.workflow_run.head_branch }} - jobs: - publish-nuget: - name: Publish (NuGet) + # Identifies the CI run whose artifacts are published, and the values needed to reproduce its version. + resolve: + name: Resolve CI run runs-on: ubuntu-24.04 if: >- - github.event.workflow_run.conclusion == 'success' && - (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && - github.event.workflow_run.head_repository.full_name == github.repository + github.event_name == 'workflow_dispatch' || + (github.event.workflow_run.conclusion == 'success' && + (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && + github.event.workflow_run.head_branch == 'main' && + github.event.workflow_run.head_repository.full_name == github.repository) permissions: - # Required to download artifacts from the triggering CI run. + # Required to look up CI runs. + actions: read + + outputs: + run-id: ${{ github.event.workflow_run.id || steps.latest.outputs.id }} + run-number: ${{ github.event.workflow_run.run_number || steps.latest.outputs.number }} + head-branch: ${{ github.event.workflow_run.head_branch || github.ref_name }} + head-sha: ${{ github.event.workflow_run.head_sha || steps.latest.outputs.sha }} + + steps: + # Automatic runs take everything from the triggering CI run, validated by the condition above. + # The query's filters give manual runs the same guarantees: a successful CI build of a commit + # pushed to this repository, never pull request code. + - name: Find latest successful CI push build + id: latest + if: github.event_name == 'workflow_dispatch' + env: + GH_TOKEN: ${{ github.token }} + shell: bash + run: | + set -euo pipefail + + run=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml --branch "$GITHUB_REF_NAME" \ + --event push --status success --limit 1 --json databaseId,number,headSha,url \ + --jq '.[0] // empty | "id=\(.databaseId)", "number=\(.number)", "sha=\(.headSha)", "url=\(.url)"') + + if [ -z "$run" ]; then + echo "::error::No successful CI push build found for branch '$GITHUB_REF_NAME'" + exit 1 + fi + + echo "$run" | tee -a "$GITHUB_OUTPUT" + + publish-nuget: + name: Publish (NuGet) + runs-on: ubuntu-24.04 + needs: resolve + + permissions: + # Required to download artifacts from the CI run. actions: read # Required for NuGet.org trusted publishing. id-token: write @@ -41,7 +83,7 @@ jobs: with: name: packages path: packages - run-id: ${{ github.event.workflow_run.id }} + run-id: ${{ needs.resolve.outputs.run-id }} github-token: ${{ github.token }} - name: Log in to NuGet uses: NuGet/login@v1 @@ -64,25 +106,26 @@ jobs: publish-npm: name: Publish (npm) runs-on: ubuntu-24.04 - - if: >- - github.event.workflow_run.conclusion == 'success' && - (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && - github.event.workflow_run.head_repository.full_name == github.repository + needs: resolve permissions: - # Required to download artifacts from the triggering CI run. + # Required to download artifacts from the CI run. actions: read contents: read # Required for npm trusted publishing and provenance. id-token: write + env: + # Reproduce the version computed by the CI run (see Get-SemVer in build/Build.Common.ps1). + CI_BUILD_NUMBER_BASE: ${{ needs.resolve.outputs.run-number }} + CI_TARGET_BRANCH: ${{ needs.resolve.outputs.head-branch }} + steps: - # Build.Npm.ps1 and the package templates under ./npm, at the commit CI built. The checks - # above guarantee this is a commit pushed to this repository, not pull request code. + # Build.Npm.ps1 and the package templates under ./npm, at the commit CI built. The resolve job + # guarantees this is a commit pushed to this repository, not pull request code. - uses: actions/checkout@v6 with: - ref: ${{ github.event.workflow_run.head_sha }} + ref: ${{ needs.resolve.outputs.head-sha }} persist-credentials: false - name: Setup uses: actions/setup-node@v7 @@ -98,7 +141,7 @@ jobs: with: name: archives path: npm-archives - run-id: ${{ github.event.workflow_run.id }} + run-id: ${{ needs.resolve.outputs.run-id }} github-token: ${{ github.token }} - name: Publish shell: pwsh diff --git a/build/README.md b/build/README.md index b6edd53a..c004c764 100644 --- a/build/README.md +++ b/build/README.md @@ -51,7 +51,11 @@ GitHub supplies no secrets or OIDC tokens to pull requests from forks, and PR bu ## The publish workflow -`publish.yml` runs via `workflow_run` when the CI workflow completes. It only publishes when that CI run succeeded, and was started by a push or manual dispatch on `dev` or `main` in this repository; it does nothing for pull requests. Two jobs run, independently: +`publish.yml` runs automatically via `workflow_run` when the CI workflow completes on `main`. It only publishes when that CI run succeeded, and was started by a push or manual dispatch in this repository; it does nothing for pull requests. + +Builds from `dev` are not published automatically. To publish one, run the **Publish** workflow manually from the Actions tab and select the `dev` branch. It publishes the latest successful CI push build of that branch. The CI run's artifacts are only retained for one day, so if that build is older, push again or re-run CI first. + +A **Resolve CI run** job first identifies the CI run, then two jobs run, independently: 1. **Publish (NuGet)** downloads the `packages` artifact from the CI run and pushes it to NuGet.org. 2. **Publish (npm)** checks out the commit CI built, downloads the `archives` artifact, and runs `Build.Npm.ps1`. @@ -63,7 +67,7 @@ Both registries use [trusted publishing](https://learn.microsoft.com/nuget/nuget | Trigger | GitHub release | NuGet | Docker Hub | npm | |---|---|---|---|---| | Pull request | no | no | no | no | -| Push to `dev` | no (unless manual `publish`) | prerelease version | `datalust/seqcli-ci:` | prerelease, dist-tag `dev` | +| Push to `dev` | no (unless manual `publish`) | prerelease version, when the publish workflow is run manually | `datalust/seqcli-ci:` | prerelease, dist-tag `dev`, when the publish workflow is run manually | | Push to `main` | yes, `v` | release version | `datalust/seqcli-ci:` | release, dist-tag `latest` | Note that `Build.Linux.ps1` always pushes to the `datalust/seqcli-ci` repository (the image name with a `-ci` suffix), never directly to `datalust/seqcli`. Promoting an image to the public `datalust/seqcli` repository, and tagging it `latest`, is a separate step outside this repository. From f5d8bcf904632d0c6c6fc25c52ff05581839d049 Mon Sep 17 00:00:00 2001 From: liammclennan-ro Date: Tue, 24 Nov 2026 11:26:14 +1000 Subject: [PATCH 2/3] Manually publish dev builds. Assisted-by: claude/fable5-2 --- .github/workflows/publish.yml | 91 ++++++++++++++++++++++++++--------- build/README.md | 8 ++- 2 files changed, 73 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1e9b6548..557f33f6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,8 @@ -# Publishes the packages built by a successful CI run to NuGet.org and npm +# Publishes the packages built by a successful CI run to NuGet.org and npm. +# +# CI runs on `main` are published automatically. Builds from other branches (e.g. `dev`) are only +# published when this workflow is run manually from the Actions tab, selecting the branch to publish; +# that publishes the latest successful CI push build of the branch. name: Publish @@ -6,27 +10,65 @@ on: workflow_run: workflows: [ "CI" ] types: [ completed ] - branches: [ "dev", "main" ] + branches: [ "main" ] + workflow_dispatch: permissions: {} -env: - # Reproduce the version computed by the triggering CI run (see Get-SemVer in build/Build.Common.ps1). - CI_BUILD_NUMBER_BASE: ${{ github.event.workflow_run.run_number }} - CI_TARGET_BRANCH: ${{ github.event.workflow_run.head_branch }} - jobs: - publish-nuget: - name: Publish (NuGet) + # Identifies the CI run whose artifacts are published, and the values needed to reproduce its version. + resolve: + name: Resolve CI run runs-on: ubuntu-24.04 if: >- - github.event.workflow_run.conclusion == 'success' && - (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && - github.event.workflow_run.head_repository.full_name == github.repository + github.event_name == 'workflow_dispatch' || + (github.event.workflow_run.conclusion == 'success' && + (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && + github.event.workflow_run.head_branch == 'main' && + github.event.workflow_run.head_repository.full_name == github.repository) permissions: - # Required to download artifacts from the triggering CI run. + # Required to look up CI runs. + actions: read + + outputs: + run-id: ${{ github.event.workflow_run.id || steps.latest.outputs.id }} + run-number: ${{ github.event.workflow_run.run_number || steps.latest.outputs.number }} + head-branch: ${{ github.event.workflow_run.head_branch || github.ref_name }} + head-sha: ${{ github.event.workflow_run.head_sha || steps.latest.outputs.sha }} + + steps: + # Automatic runs take everything from the triggering CI run, validated by the condition above. + # The query's filters give manual runs the same guarantees: a successful CI build of a commit + # pushed to this repository, never pull request code. + - name: Find latest successful CI push build + id: latest + if: github.event_name == 'workflow_dispatch' + env: + GH_TOKEN: ${{ github.token }} + shell: bash + run: | + set -euo pipefail + + run=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml --branch "$GITHUB_REF_NAME" \ + --event push --status success --limit 1 --json databaseId,number,headSha,url \ + --jq '.[0] // empty | "id=\(.databaseId)", "number=\(.number)", "sha=\(.headSha)", "url=\(.url)"') + + if [ -z "$run" ]; then + echo "::error::No successful CI push build found for branch '$GITHUB_REF_NAME'" + exit 1 + fi + + echo "$run" | tee -a "$GITHUB_OUTPUT" + + publish-nuget: + name: Publish (NuGet) + runs-on: ubuntu-24.04 + needs: resolve + + permissions: + # Required to download artifacts from the CI run. actions: read # Required for NuGet.org trusted publishing. id-token: write @@ -41,7 +83,7 @@ jobs: with: name: packages path: packages - run-id: ${{ github.event.workflow_run.id }} + run-id: ${{ needs.resolve.outputs.run-id }} github-token: ${{ github.token }} - name: Log in to NuGet uses: NuGet/login@v1 @@ -64,25 +106,26 @@ jobs: publish-npm: name: Publish (npm) runs-on: ubuntu-24.04 - - if: >- - github.event.workflow_run.conclusion == 'success' && - (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && - github.event.workflow_run.head_repository.full_name == github.repository + needs: resolve permissions: - # Required to download artifacts from the triggering CI run. + # Required to download artifacts from the CI run. actions: read contents: read # Required for npm trusted publishing and provenance. id-token: write + env: + # Reproduce the version computed by the CI run (see Get-SemVer in build/Build.Common.ps1). + CI_BUILD_NUMBER_BASE: ${{ needs.resolve.outputs.run-number }} + CI_TARGET_BRANCH: ${{ needs.resolve.outputs.head-branch }} + steps: - # Build.Npm.ps1 and the package templates under ./npm, at the commit CI built. The checks - # above guarantee this is a commit pushed to this repository, not pull request code. + # Build.Npm.ps1 and the package templates under ./npm, at the commit CI built. The resolve job + # guarantees this is a commit pushed to this repository, not pull request code. - uses: actions/checkout@v6 with: - ref: ${{ github.event.workflow_run.head_sha }} + ref: ${{ needs.resolve.outputs.head-sha }} persist-credentials: false - name: Setup uses: actions/setup-node@v7 @@ -98,7 +141,7 @@ jobs: with: name: archives path: npm-archives - run-id: ${{ github.event.workflow_run.id }} + run-id: ${{ needs.resolve.outputs.run-id }} github-token: ${{ github.token }} - name: Publish shell: pwsh diff --git a/build/README.md b/build/README.md index b6edd53a..c004c764 100644 --- a/build/README.md +++ b/build/README.md @@ -51,7 +51,11 @@ GitHub supplies no secrets or OIDC tokens to pull requests from forks, and PR bu ## The publish workflow -`publish.yml` runs via `workflow_run` when the CI workflow completes. It only publishes when that CI run succeeded, and was started by a push or manual dispatch on `dev` or `main` in this repository; it does nothing for pull requests. Two jobs run, independently: +`publish.yml` runs automatically via `workflow_run` when the CI workflow completes on `main`. It only publishes when that CI run succeeded, and was started by a push or manual dispatch in this repository; it does nothing for pull requests. + +Builds from `dev` are not published automatically. To publish one, run the **Publish** workflow manually from the Actions tab and select the `dev` branch. It publishes the latest successful CI push build of that branch. The CI run's artifacts are only retained for one day, so if that build is older, push again or re-run CI first. + +A **Resolve CI run** job first identifies the CI run, then two jobs run, independently: 1. **Publish (NuGet)** downloads the `packages` artifact from the CI run and pushes it to NuGet.org. 2. **Publish (npm)** checks out the commit CI built, downloads the `archives` artifact, and runs `Build.Npm.ps1`. @@ -63,7 +67,7 @@ Both registries use [trusted publishing](https://learn.microsoft.com/nuget/nuget | Trigger | GitHub release | NuGet | Docker Hub | npm | |---|---|---|---|---| | Pull request | no | no | no | no | -| Push to `dev` | no (unless manual `publish`) | prerelease version | `datalust/seqcli-ci:` | prerelease, dist-tag `dev` | +| Push to `dev` | no (unless manual `publish`) | prerelease version, when the publish workflow is run manually | `datalust/seqcli-ci:` | prerelease, dist-tag `dev`, when the publish workflow is run manually | | Push to `main` | yes, `v` | release version | `datalust/seqcli-ci:` | release, dist-tag `latest` | Note that `Build.Linux.ps1` always pushes to the `datalust/seqcli-ci` repository (the image name with a `-ci` suffix), never directly to `datalust/seqcli`. Promoting an image to the public `datalust/seqcli` repository, and tagging it `latest`, is a separate step outside this repository. From 2a2d397bddc460ee7436976a93dbd75a8c407882 Mon Sep 17 00:00:00 2001 From: liammclennan-ro Date: Tue, 24 Nov 2026 12:50:07 +1000 Subject: [PATCH 3/3] Remove manual publish from ci.yml. --- .github/workflows/ci.yml | 11 ++--------- .github/workflows/publish.yml | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 668693bb..3889afef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# If this file is renamed, the incrementing run attempt number will be reset. If the workflow's +# If this file is renamed, the incrementing run number will be reset. If the workflow's # `name` changes, the `workflow_run` trigger in publish.yml must be updated. name: CI @@ -8,18 +8,11 @@ on: branches: [ "dev", "main" ] pull_request: branches: [ "dev", "main" ] - workflow_dispatch: - inputs: - publish: - description: 'Publish a GitHub release' - type: boolean - required: true - default: true env: CI_BUILD_NUMBER_BASE: ${{ github.run_number }} CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} - CI_PUBLISH: ${{ (github.event_name == 'push' && github.ref_name == 'main') || inputs.publish }} + CI_PUBLISH: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev'))}} jobs: build-windows: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 557f33f6..0973dfba 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,7 +24,7 @@ jobs: if: >- github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && - (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch') && + github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.head_repository.full_name == github.repository)