Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

ci(cua-spaces): add rebuild_tag dispatch to publish an existing tag with main's workflow files (#6649)

Francesco Bonaccic858746ac78a
diff --git a/.github/scripts/tests/test_cua_sdk_release_repository.py b/.github/scripts/tests/test_cua_sdk_release_repository.py
index 75e810839a..c355690a54 100644
--- a/.github/scripts/tests/test_cua_sdk_release_repository.py
+++ b/.github/scripts/tests/test_cua_sdk_release_repository.py
@@ -77,7 +77,8 @@ def test_spaces_builds_use_the_release_config_overlay() -> None:
def test_spaces_signing_fails_closed_only_on_trycua_cua() -> None:
wf = workflow("cd-cua-spaces.yml")
assert wf["env"]["REQUIRE_SIGNING"] == (
- "${{ github.repository == 'trycua/cua' && startsWith(github.ref, 'refs/tags/') }}"
+ "${{ github.repository == 'trycua/cua' && (startsWith(github.ref, 'refs/tags/') "
+ "|| (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != '')) }}"
)
gate = step("cd-cua-spaces.yml", "build-macos", "Signing configuration")["run"]
assert 'elif [ "$REQUIRE_SIGNING" = true ]; then' in gate
diff --git a/.github/scripts/tests/test_cua_spaces_rebuild_wiring.py b/.github/scripts/tests/test_cua_spaces_rebuild_wiring.py
new file mode 100644
index 0000000000..6fe491b2c9
--- /dev/null
+++ b/.github/scripts/tests/test_cua_spaces_rebuild_wiring.py
@@ -0,0 +1,183 @@
+"""Contract for the Cua Spaces rebuild dispatch (rebuild_tag, rebuild_sha).
+
+An existing stable tag whose tag-push run never published can be rebuilt and
+published from a workflow_dispatch on main, with main's workflow files. Every
+release gate must behave exactly as on a tag push, a published release must be
+refused, and no tag is ever moved or created.
+"""
+
+from pathlib import Path
+
+import yaml
+
+ROOT = Path(__file__).resolve().parents[3]
+CD = ROOT / ".github/workflows/cd-cua-spaces.yml"
+TAG_RUN = (
+ "(startsWith(github.ref, 'refs/tags/cua-spaces-v') || "
+ "(github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != ''))"
+)
+# Jobs that build or verify the tagged source check out the tagged commit.
+SOURCE_JOBS = {
+ "spacesd-published",
+ "macos-rust",
+ "build-macos",
+ "build-linux-windows",
+ "electron-plan",
+ "electron-web",
+ "electron-native",
+ "electron-native-mac",
+ "electron-mac",
+ "electron-windows-pkg",
+ "electron-windows",
+ "electron-linux-pkg",
+ "electron-publish",
+ "verify-release",
+}
+# Publishing and gate tooling stays on main, so fixed workflow files and the
+# current installers apply to the old tag.
+MAIN_TOOLING_JOBS = {
+ "request-staging-smoke",
+ "promote-check",
+ "staging-gate",
+ "installer-manifest",
+ "site-follows-release",
+}
+CHECKOUT_REF = "${{ inputs.rebuild_sha || github.sha }}"
+
+
+def load():
+ text = CD.read_text()
+ return text, yaml.safe_load(text)
+
+
+def dispatch_inputs(workflow):
+ return workflow[True]["workflow_dispatch"]["inputs"] # PyYAML reads `on` as True
+
+
+def test_rebuild_inputs_exist_and_default_empty():
+ _, workflow = load()
+ inputs = dispatch_inputs(workflow)
+ for name in ("rebuild_tag", "rebuild_sha"):
+ assert inputs[name]["default"] == ""
+ assert inputs[name]["required"] is False
+ assert "push" in workflow[True] # the tag push is still the normal path
+
+
+def test_release_identity_comes_from_the_rebuilt_tag():
+ text, workflow = load()
+ env = workflow["env"]
+ assert env["RELEASE_REF"] == (
+ "${{ inputs.rebuild_tag && format('refs/tags/{0}', inputs.rebuild_tag) || github.ref }}"
+ )
+ assert env["RELEASE_REF_NAME"] == "${{ inputs.rebuild_tag || github.ref_name }}"
+ assert env["RELEASE_SHA"] == "${{ inputs.rebuild_sha || github.sha }}"
+ assert "inputs.rebuild_tag != ''" in env["REQUIRE_SIGNING"]
+ concurrency = workflow["concurrency"]
+ # A rebuild shares the tag's group (never two runs of one release) and is
+ # never cancelled.
+ assert "format('refs/tags/{0}', inputs.rebuild_tag)" in concurrency["group"]
+ assert "!inputs.rebuild_tag" in concurrency["cancel-in-progress"]
+ # No shell step reads the dispatch ref or SHA as if it were the release.
+ for forbidden in ("$GITHUB_REF_NAME", "${GITHUB_REF_NAME", '"$GITHUB_SHA"'):
+ if forbidden == '"$GITHUB_SHA"':
+ # Only the prerelease notes name the run's own ref and SHA.
+ assert text.count(forbidden) == 0, forbidden
+ else:
+ assert forbidden not in text, forbidden
+
+
+def test_every_release_gate_keys_on_a_tag_run_including_a_rebuild():
+ text, workflow = load()
+ jobs = workflow["jobs"]
+ for job in ("request-staging-smoke", "staging-gate"):
+ assert jobs[job]["if"].strip() == TAG_RUN, job
+ assert jobs["promote-check"]["if"].strip() == f"{TAG_RUN} && vars.CUA_SPACES_PROMOTE_CHECK == 'true'"
+ assert TAG_RUN in jobs["installer-manifest"]["if"]
+ assert TAG_RUN in jobs["site-follows-release"]["if"]
+ assert "github.repository == 'trycua/cua'" in jobs["site-follows-release"]["if"]
+ # No tag-only condition is left behind.
+ bare = "startsWith(github.ref, 'refs/tags/cua-spaces-v')"
+ assert text.count(bare) == text.count(TAG_RUN)
+ # The release commit, not main's tip, is smoked and gated.
+ assert 'request_staging_smoke.sh cua-spaces "$RELEASE_SHA"' in text
+ assert 'require_staging_smoke.sh cua-spaces "$RELEASE_SHA"' in text
+ # Signing, tag-only publishing and the draft step key on the same switch.
+ assert f"TAGGED: ${{{{ {TAG_RUN} }}}}" in text
+ assert f"if: {TAG_RUN}\n" in text
+ # electron-plan plans a rebuild like a tag push (platform patch diff).
+ assert "'workflow_dispatch' && inputs.rebuild_tag == '' && 'workflow_dispatch' || 'push'" in text
+ assert text.count('[[ "$RELEASE_REF" == refs/tags/cua-spaces-v* ]]') == 2
+
+
+def test_source_jobs_build_the_tagged_commit_and_tooling_jobs_keep_main():
+ _, workflow = load()
+ for name, job in workflow["jobs"].items():
+ checkouts = [s for s in job.get("steps", []) if str(s.get("uses", "")).startswith("actions/checkout@")]
+ refs = [(c.get("with") or {}).get("ref") for c in checkouts]
+ if name in SOURCE_JOBS:
+ assert checkouts and all(r == CHECKOUT_REF for r in refs), name
+ elif name in MAIN_TOOLING_JOBS:
+ assert all(r is None for r in refs), name
+
+
+def test_version_comes_from_the_rebuilt_tag_not_the_dispatch_input():
+ text, _ = load()
+ guard = 'if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -z "${REBUILD_TAG:-}" ]; then'
+ assert text.count(guard) == 3
+ assert "${RELEASE_REF_NAME#cua-spaces-v}" in text
+ assert text.count("${{ github.event.inputs.version }}") == 3
+ assert "REBUILD_TAG" in text.split("refuse-beta:", 1)[1].split("spacesd-published:", 1)[0]
+
+
+def validate_step(workflow):
+ steps = workflow["jobs"]["refuse-beta"]["steps"]
+ step = next(s for s in steps if s["name"] == "Validate rebuild request")
+ # After the beta refusal, which stays the first step of the first job.
+ assert steps.index(step) == 1
+ assert step["if"] == "${{ inputs.rebuild_tag != '' }}"
+ return step
+
+
+def test_rebuild_guard_refuses_everything_unsafe():
+ _, workflow = load()
+ step = validate_step(workflow)
+ run = step["run"]
+ # Only main's workflow files, only a stable tag, only the tagged commit.
+ assert '"$GITHUB_EVENT_NAME" == "workflow_dispatch" && "$WORKFLOW_REF" == "refs/heads/main"' in run
+ assert r"^cua-spaces-v[0-9]+\.[0-9]+\.[0-9]+$" in run
+ assert "^[0-9a-f]{40}$" in run
+ assert 'commits/${REBUILD_TAG}" --jq .sha' in run
+ assert '"$TAG_SHA" == "$REBUILD_SHA"' in run
+ # Never a duplicate: a published release of the tag is refused.
+ assert '.tag_name == \\"${REBUILD_TAG}\\" and .draft == false' in run
+ assert "already published" in run
+ # No manual-run switch changes a gate for a rebuild.
+ for switch in ("DRY_RUN", "SPARKLE_INPUT", "SKIP_STAGING_GATE", "PLATFORMS"):
+ assert switch in step["env"]
+ assert '"$PLATFORMS" == "all"' in run
+ # Nothing moves or creates a tag.
+ assert "git " not in run and "gh release create" not in run
+ # The guard can see draft releases, and the beta refusal still follows it.
+ assert workflow["jobs"]["refuse-beta"]["permissions"] == {"contents": "write"}
+ names = [s["name"] for s in workflow["jobs"]["refuse-beta"]["steps"]]
+ assert names == ["Refuse beta versions", "Validate rebuild request"]
+
+
+def test_publish_still_requires_every_gate():
+ _, workflow = load()
+ job = workflow["jobs"]["installer-manifest"]
+ needs = job["needs"]
+ for gate in ("verify-release", "staging-gate", "electron-publish", "build-macos"):
+ assert gate in needs
+ for result in ("verify-release", "staging-gate"):
+ assert f"needs.{result}.result == 'success'" in job["if"]
+ assert job["permissions"]["id-token"] == "write"
+
+
+def test_installers_accept_the_main_identity_of_a_rebuild_only_for_the_app():
+ sh = (ROOT / "scripts/install/install.sh").read_text()
+ ps1 = (ROOT / "scripts/install/install.ps1").read_text()
+ assert "cd-cua-spaces.yml@refs/heads/main" in sh
+ assert "cd-cua-spaces.yml@refs/heads/main" in ps1
+ assert "cd-cua-sdk.yml@refs/heads" not in sh + ps1
+ assert "identity-regexp" not in sh + ps1
diff --git a/.github/workflows/cd-cua-spaces.yml b/.github/workflows/cd-cua-spaces.yml
index 78d15bd294..0b81d325c6 100644
--- a/.github/workflows/cd-cua-spaces.yml
+++ b/.github/workflows/cd-cua-spaces.yml
@@ -97,7 +97,13 @@ name: "CD: Cua Spaces"
# apps/cua-spaces shares it as extra files but never triggers a release) and
# creates a draft release plus the `cua-spaces-v<version>` tag; this
# workflow fills that release and publishes it. It can also run manually with
-# an explicit version. The macOS app takes the tag's version:
+# an explicit version. A tag whose run never published (the workflow itself was
+# broken) is rebuilt by a dispatch from main with rebuild_tag and rebuild_sha:
+# it builds the tagged commit with main's workflow files, refuses a release
+# that is already published, and runs every gate (signing, notarization,
+# staging smoke, verify-release, staged rollout) exactly as the tag push does.
+# Its Sigstore identity is this workflow at refs/heads/main, which the
+# installers accept for the app next to the tag identity. The macOS app takes the tag's version:
# CFBundleShortVersionString X.Y.Z, CFBundleVersion X.Y.Z.<run number>, and
# the full version (with any -suffix) as CuaVersion.
#
@@ -189,7 +195,7 @@ on:
workflow_dispatch:
inputs:
version:
- description: "Version to release (without the v prefix, e.g. 0.1.0)"
+ description: "Version to release (without the v prefix, e.g. 0.1.0). Ignored with rebuild_tag, which carries its own version."
required: true
default: "0.1.0"
electron_dry_run:
@@ -216,6 +222,14 @@ on:
description: "Why the staging gate is skipped (required with skip_staging_gate)"
required: false
default: ""
+ rebuild_tag:
+ description: "Rebuild and publish the existing unpublished release of this stable tag (e.g. cua-spaces-v0.21.0) with THIS ref's workflow files. Run from main. Leave empty for a normal manual run."
+ required: false
+ default: ""
+ rebuild_sha:
+ description: "Commit SHA the tag points to (required with rebuild_tag; checked against the tag)"
+ required: false
+ default: ""
permissions:
contents: write
@@ -224,8 +238,8 @@ permissions:
# whatever the group (a second run of the same tag waits its turn). Manual
# runs (tests and dry runs) share a group per branch and replace each other.
concurrency:
- group: cd-cua-spaces-${{ github.ref }}
- cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
+ group: cd-cua-spaces-${{ inputs.rebuild_tag && format('refs/tags/{0}', inputs.rebuild_tag) || github.ref }}
+ cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') && !inputs.rebuild_tag }}
defaults:
run:
@@ -241,7 +255,16 @@ env:
# The CLI sidecar downloads cua-spacesd from this repository's releases.
CUA_RELEASE_REPOSITORY: ${{ github.repository }}
# Fail closed on the canonical repository only (see the header).
- REQUIRE_SIGNING: ${{ github.repository == 'trycua/cua' && startsWith(github.ref, 'refs/tags/') }}
+ REQUIRE_SIGNING: ${{ github.repository == 'trycua/cua' && (startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != '')) }}
+ # The release this run is about: the pushed tag or, for a rebuild dispatch
+ # (run from main so fixed workflow files apply to an existing tag), the
+ # requested tag. Shell steps read these instead of GITHUB_REF, GITHUB_REF_NAME
+ # and GITHUB_SHA. Build jobs check out RELEASE_SHA; the publishing and gate
+ # jobs keep main's tooling.
+ REBUILD_TAG: ${{ inputs.rebuild_tag }}
+ RELEASE_REF: ${{ inputs.rebuild_tag && format('refs/tags/{0}', inputs.rebuild_tag) || github.ref }}
+ RELEASE_REF_NAME: ${{ inputs.rebuild_tag || github.ref_name }}
+ RELEASE_SHA: ${{ inputs.rebuild_sha || github.sha }}
jobs:
# No betas (CUA-3503): pre-release testing is the Nightly channel
@@ -253,7 +276,9 @@ jobs:
name: Refuse beta versions
runs-on: ubuntu-latest
timeout-minutes: 5
- permissions: {}
+ # contents: write so the rebuild guard can see draft releases.
+ permissions:
+ contents: write
# This job has no checkout, so the workflow-wide apps/cua-spaces default
# does not exist on the runner and the step cannot start.
defaults:
@@ -262,12 +287,11 @@ jobs:
steps:
- name: Refuse beta versions
env:
- REF_NAME: ${{ github.ref_name }}
INPUT_VERSION: ${{ inputs.version }}
ALLOW_SPACES_BETA: ${{ vars.ALLOW_SPACES_BETA }}
run: |
version="$INPUT_VERSION"
- [ "$GITHUB_EVENT_NAME" = push ] && version="${REF_NAME#cua-spaces-v}"
+ { [ "$GITHUB_EVENT_NAME" = push ] || [ -n "$REBUILD_TAG" ]; } && version="${RELEASE_REF_NAME#cua-spaces-v}"
case "$version" in
*-beta*)
if [ "$ALLOW_SPACES_BETA" = true ]; then
@@ -278,6 +302,41 @@ jobs:
fi ;;
esac
+ # Rebuild dispatch guard: only main's workflow files, only a stable tag,
+ # only the exact tagged commit, and never a release that is already
+ # published, so a rebuild can never duplicate or replace one. Nothing here
+ # moves or re-creates a tag.
+ - name: Validate rebuild request
+ if: ${{ inputs.rebuild_tag != '' }}
+ env:
+ GH_TOKEN: ${{ github.token }}
+ REBUILD_SHA: ${{ inputs.rebuild_sha }}
+ WORKFLOW_REF: ${{ github.ref }}
+ DRY_RUN: ${{ inputs.electron_dry_run }}
+ SPARKLE_INPUT: ${{ inputs.sparkle_electron }}
+ PLATFORMS: ${{ inputs.platforms }}
+ SKIP_STAGING_GATE: ${{ inputs.skip_staging_gate }}
+ run: |
+ set -euo pipefail
+ [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && "$WORKFLOW_REF" == "refs/heads/main" ]] \
+ || { echo "::error::rebuild_tag is only allowed on a workflow_dispatch from main"; exit 1; }
+ [[ "$REBUILD_TAG" =~ ^cua-spaces-v[0-9]+\.[0-9]+\.[0-9]+$ ]] \
+ || { echo "::error::rebuild_tag must be a stable cua-spaces-vX.Y.Z tag"; exit 1; }
+ [[ "$REBUILD_SHA" =~ ^[0-9a-f]{40}$ ]] \
+ || { echo "::error::rebuild_sha must be a full lowercase commit SHA"; exit 1; }
+ # A rebuild runs every gate exactly as a tag push does: none of the
+ # manual-run switches apply.
+ [[ "$DRY_RUN" != "true" && "$SPARKLE_INPUT" != "true" && "$SKIP_STAGING_GATE" != "true" && "$PLATFORMS" == "all" ]] \
+ || { echo "::error::a rebuild takes no electron_dry_run, sparkle_electron, skip_staging_gate or platforms"; exit 1; }
+ TAG_SHA=$(gh api "repos/${GITHUB_REPOSITORY}/commits/${REBUILD_TAG}" --jq .sha)
+ [[ "$TAG_SHA" == "$REBUILD_SHA" ]] \
+ || { echo "::error::$REBUILD_TAG resolves to $TAG_SHA, not $REBUILD_SHA"; exit 1; }
+ PUBLISHED=$(gh api "repos/${GITHUB_REPOSITORY}/releases?per_page=100" --paginate \
+ --jq ".[] | select(.tag_name == \"${REBUILD_TAG}\" and .draft == false) | .id")
+ [[ -z "$PUBLISHED" ]] \
+ || { echo "::error::$REBUILD_TAG is already published; refusing to rebuild"; exit 1; }
+ echo "Rebuilding $REBUILD_TAG at $REBUILD_SHA from main's workflow files." >> "$GITHUB_STEP_SUMMARY"
+
# The bundled `cua` CLI bakes libs/cua-spacesd/VERSION and "Set up for
# access" downloads that release: refuse to build an app whose pinned
# cua-spacesd is not published (Cua Spaces 0.3.0 pinned a draft).
@@ -293,6 +352,8 @@ jobs:
contents: read
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- name: Check the baked cua-spacesd release
env:
GH_TOKEN: ${{ github.token }}
@@ -325,6 +386,8 @@ jobs:
- { arch: x86_64, triple: x86_64-apple-darwin }
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
# One definition with the main-branch producer
# (ci-cua-spaces-rust-slice.yml): same key, restore or build.
- uses: ./.github/actions/spaces-rust-slice
@@ -379,14 +442,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- name: Resolve version
id: version
run: |
- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -z "${REBUILD_TAG:-}" ]; then
VERSION="${{ github.event.inputs.version }}"
else
- VERSION="${GITHUB_REF_NAME#cua-spaces-v}"
+ VERSION="${RELEASE_REF_NAME#cua-spaces-v}"
fi
# A semver prerelease, or any build off the canonical repository,
# becomes a GitHub prerelease (never "latest").
@@ -450,7 +515,7 @@ jobs:
# staging prerelease, a recovery) gets one here. Every job uploads to it
# and the final job publishes it.
- name: Find or create the draft release
- if: startsWith(github.ref, 'refs/tags/')
+ if: (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != ''))
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
@@ -671,7 +736,7 @@ jobs:
echo "darwin-universal: UNSIGNED (ad-hoc signed app, unsigned DMG and PKG, not notarized)" > signing-darwin-universal.txt
fi
shasum -a 256 installer-assets/*
- if [[ "$GITHUB_REF" == refs/tags/* ]]; then
+ if [[ "$RELEASE_REF" == refs/tags/* ]]; then
gh release upload "cua-spaces-v${VERSION}" installer-assets/* --clobber --repo "${GITHUB_REPOSITORY}"
fi
@@ -762,9 +827,11 @@ jobs:
runs-on: ${{ matrix.os }}
env:
CARGO_BUILD_JOBS: 4
- TAGGED: ${{ startsWith(github.ref, 'refs/tags/') }}
+ TAGGED: ${{ (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != '')) }}
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- uses: actions/setup-node@v4
with:
@@ -794,10 +861,10 @@ jobs:
id: version
shell: bash
run: |
- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -z "${REBUILD_TAG:-}" ]; then
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
- echo "version=${GITHUB_REF_NAME#cua-spaces-v}" >> "$GITHUB_OUTPUT"
+ echo "version=${RELEASE_REF_NAME#cua-spaces-v}" >> "$GITHUB_OUTPUT"
fi
- name: Tauri release config (version, updater feed on this repository)
shell: bash
@@ -1001,13 +1068,14 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
# The path diff against the previous release tag.
fetch-depth: 0
- name: Plan
id: plan
env:
GH_TOKEN: ${{ github.token }}
- EVENT: ${{ github.event_name }}
+ EVENT: ${{ github.event_name == 'workflow_dispatch' && inputs.rebuild_tag == '' && 'workflow_dispatch' || 'push' }}
INPUT_PLATFORMS: ${{ github.event_name == 'workflow_dispatch' && inputs.platforms || 'all' }}
INPUT_PLATFORMS_REASON: ${{ github.event_name == 'workflow_dispatch' && inputs.platforms_reason || '' }}
INPUT_VERSION: ${{ inputs.version }}
@@ -1016,7 +1084,7 @@ jobs:
SPARKLE_VERSION: ${{ vars.CUA_SPACES_SPARKLE_ELECTRON_VERSION }}
run: |
set -euo pipefail
- if [ "$EVENT" = workflow_dispatch ]; then VERSION="$INPUT_VERSION"; else VERSION="${GITHUB_REF_NAME#cua-spaces-v}"; fi
+ if [ "$EVENT" = workflow_dispatch ]; then VERSION="$INPUT_VERSION"; else VERSION="${RELEASE_REF_NAME#cua-spaces-v}"; fi
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::bad version: $VERSION"; exit 1; }
beta=false; [[ "$VERSION" == *-* ]] && beta=true
# The Sparkle cutover: one release, named by the variable or the input.
@@ -1033,10 +1101,10 @@ jobs:
# Windows and Linux Electron: every release tag (stable too), the
# cutover and a dry run. `build` above is the macOS Electron app only.
desktop=false
- { [ "$build" = true ] || [[ "$GITHUB_REF" == refs/tags/cua-spaces-v* ]]; } && desktop=true
+ { [ "$build" = true ] || [[ "$RELEASE_REF" == refs/tags/cua-spaces-v* ]]; } && desktop=true
# Any release tag publishes; a dry run never does.
publish=false
- if [ "$DRY_RUN" != true ] && [[ "$GITHUB_REF" == refs/tags/cua-spaces-v* ]]; then publish=true; fi
+ if [ "$DRY_RUN" != true ] && [[ "$RELEASE_REF" == refs/tags/cua-spaces-v* ]]; then publish=true; fi
# A semver prerelease, or any build off the canonical repository,
# is a GitHub prerelease (never "latest").
prerelease=false
@@ -1140,6 +1208,8 @@ jobs:
contents: read
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: dtolnay/[email protected]
with:
targets: wasm32-unknown-unknown
@@ -1175,7 +1245,7 @@ jobs:
- name: Resolve version
id: version
run: |
- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then VERSION="${{ github.event.inputs.version }}"; else VERSION="${GITHUB_REF_NAME#cua-spaces-v}"; fi
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -z "${REBUILD_TAG:-}" ]; then VERSION="${{ github.event.inputs.version }}"; else VERSION="${RELEASE_REF_NAME#cua-spaces-v}"; fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Upload the web UI source maps to Sentry
uses: ./.github/actions/sentry-upload
@@ -1216,6 +1286,8 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: ./.github/actions/spaces-native
with:
label: ${{ matrix.label }}
@@ -1247,6 +1319,8 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: ./.github/actions/spaces-native
with:
label: ${{ matrix.label }}
@@ -1284,6 +1358,8 @@ jobs:
VERSION: ${{ needs.electron-plan.outputs.version }}
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- name: Signing configuration
id: signing
env:
@@ -1563,6 +1639,8 @@ jobs:
CUA_SPACES_ARCHS: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- name: Signing configuration
id: signing
env:
@@ -1708,6 +1786,8 @@ jobs:
working-directory: .
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: actions/setup-node@v4
with:
node-version: 22
@@ -1763,6 +1843,8 @@ jobs:
CUA_SPACES_ARCHS: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
with:
package_json_file: apps/cua-spaces-desktop/package.json
@@ -1861,6 +1943,8 @@ jobs:
working-directory: .
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- uses: actions/setup-node@v4
with:
node-version: 22
@@ -1964,7 +2048,7 @@ jobs:
request-staging-smoke:
name: Request the staging smoke
needs: refuse-beta
- if: startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ if: (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != ''))
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
@@ -1987,7 +2071,7 @@ jobs:
- name: Send the cua-release-candidate dispatch
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- run: .github/scripts/request_staging_smoke.sh cua-spaces "$GITHUB_SHA"
+ run: .github/scripts/request_staging_smoke.sh cua-spaces "$RELEASE_SHA"
# Promote check (CUA-2067, phase 2 of CUA-1991). Looks for the signed set the
# main build made for this tag's commit and verifies it the way a promotion
@@ -1999,7 +2083,7 @@ jobs:
promote-check:
name: Promote check (report only)
needs: refuse-beta
- if: startsWith(github.ref, 'refs/tags/cua-spaces-v') && vars.CUA_SPACES_PROMOTE_CHECK == 'true'
+ if: (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != '')) && vars.CUA_SPACES_PROMOTE_CHECK == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
continue-on-error: true
@@ -2021,18 +2105,18 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
set -uo pipefail
- version="${GITHUB_REF_NAME#cua-spaces-v}"
+ version="${RELEASE_REF_NAME#cua-spaces-v}"
report() { echo "$1" | tee -a "$GITHUB_STEP_SUMMARY"; }
echo "promotable=false" >> "$GITHUB_OUTPUT"
- run_id="$(gh run list --workflow cd-cua-spaces-build.yml --branch main --commit "$GITHUB_SHA" \
+ run_id="$(gh run list --workflow cd-cua-spaces-build.yml --branch main --commit "$RELEASE_SHA" \
--status success --limit 1 --json databaseId --jq '.[0].databaseId // empty')"
- if [ -z "$run_id" ]; then report "No successful main build for $GITHUB_SHA: this tag would fall back to the full build."; exit 0; fi
- if ! gh run download "$run_id" --name "spaces-build-$GITHUB_SHA" --dir set; then
- report "Main build run $run_id has no spaces-build-$GITHUB_SHA artifact (expired, or the build was a no-op): this tag would fall back to the full build."; exit 0
+ if [ -z "$run_id" ]; then report "No successful main build for $RELEASE_SHA: this tag would fall back to the full build."; exit 0; fi
+ if ! gh run download "$run_id" --name "spaces-build-$RELEASE_SHA" --dir set; then
+ report "Main build run $run_id has no spaces-build-$RELEASE_SHA artifact (expired, or the build was a no-op): this tag would fall back to the full build."; exit 0
fi
- out="$(python3 -I .github/scripts/spaces_verify_build_set.py set --tag-version "$version" --tag-sha "$GITHUB_SHA" --repository "$GITHUB_REPOSITORY")"
+ out="$(python3 -I .github/scripts/spaces_verify_build_set.py set --tag-version "$version" --tag-sha "$RELEASE_SHA" --repository "$GITHUB_REPOSITORY")"
rc=$?
- report "### Promote check for $GITHUB_REF_NAME (main build run $run_id)"
+ report "### Promote check for $RELEASE_REF_NAME (main build run $run_id)"
report '```'
report "$out"
report '```'
@@ -2051,7 +2135,7 @@ jobs:
staging-gate:
name: Staging smoke is green
needs: refuse-beta
- if: startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ if: (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != ''))
runs-on: ubuntu-latest
# Waits up to 2 hours for the smoke that request-staging-smoke starts:
# the smoke can sit in trycua/cloud's queue for half an hour before it
@@ -2072,7 +2156,7 @@ jobs:
SKIP_STAGING_GATE: ${{ github.event_name == 'workflow_dispatch' && inputs.skip_staging_gate }}
SKIP_REASON: ${{ github.event_name == 'workflow_dispatch' && inputs.skip_staging_reason || '' }}
WAIT_MINUTES: "120"
- run: .github/scripts/require_staging_smoke.sh cua-spaces "$GITHUB_SHA"
+ run: .github/scripts/require_staging_smoke.sh cua-spaces "$RELEASE_SHA"
verify-release:
name: Verify the signed release
@@ -2104,6 +2188,8 @@ jobs:
APPCAST: ${{ needs.build-macos.outputs.appcast == 'true' || needs.electron-mac.outputs.appcast == 'true' }}
steps:
- uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.rebuild_sha || github.sha }}
- if: needs.electron-plan.outputs.macos == 'true'
uses: actions/download-artifact@v4
with:
@@ -2182,15 +2268,16 @@ jobs:
name: release-artifacts.json, latest.json, publish
needs: [build-macos, build-linux-windows, electron-plan, electron-mac, electron-publish, verify-release, staging-gate]
# Only a release tag publishes: the Sigstore identity the installers and
- # the updater feed trust is cd-cua-spaces.yml at refs/tags/cua-spaces-v*.
- # A manual run from a tag re-publishes; from a branch it only builds.
+ # the updater feed trust is cd-cua-spaces.yml at refs/tags/cua-spaces-v*,
+ # or at refs/heads/main for a rebuild of an existing tag (rebuild_tag).
+ # A manual run from a branch without rebuild_tag only builds.
# build-linux-windows (Tauri) may be skipped, never failed; electron-mac is
# skipped on a stable release. A release tag waits for its Electron
# installers (electron-publish).
# Nothing is published unless verify-release passed.
# build-macos is skipped (not failed) in a patch release without macOS.
if: >-
- !cancelled() && startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ !cancelled() && (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != ''))
&& (needs.electron-plan.outputs.macos != 'true' || needs.build-macos.result == 'success')
&& needs.verify-release.result == 'success'
&& needs.staging-gate.result == 'success'
@@ -2450,7 +2537,7 @@ jobs:
needs: [installer-manifest, electron-plan]
if: >-
!cancelled() && needs.installer-manifest.result == 'success'
- && startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ && (startsWith(github.ref, 'refs/tags/cua-spaces-v') || (github.event_name == 'workflow_dispatch' && inputs.rebuild_tag != ''))
&& github.repository == 'trycua/cua'
&& needs.electron-plan.outputs.prerelease != 'true'
runs-on: ubuntu-latest
diff --git a/docs/contributing/releasing-cua-spaces.md b/docs/contributing/releasing-cua-spaces.md
index c392df0358..5936d9c214 100644
--- a/docs/contributing/releasing-cua-spaces.md
+++ b/docs/contributing/releasing-cua-spaces.md
@@ -57,3 +57,24 @@ allow one in an emergency, set the repository variable `ALLOW_SPACES_BETA` to
`true` (Settings, Secrets and variables, Actions, Variables), then delete it
right after. Betas published before November 2026 remain as prereleases;
their items in the beta feeds are no longer updated.
+
+## Rebuilding a tag whose run never published
+
+If a tag exists but its tag-push run never published (for example the workflow
+itself was broken), do not move or delete the tag. Dispatch the workflow from
+`main`, which carries the fix, with the tag and its commit:
+
+```sh
+gh workflow run cd-cua-spaces.yml -R trycua/cua --ref main \
+ -f rebuild_tag=cua-spaces-vX.Y.Z -f rebuild_sha=<full commit SHA of the tag>
+```
+
+The run builds the tagged commit with `main`'s workflow files and publishes
+the existing draft release (or creates it for that tag). It refuses a release
+that is already published, a tag that does not point at `rebuild_sha`, a
+non-stable tag, and a dispatch from any other branch. Every gate runs exactly
+as on a tag push: signing, notarization, the staging smoke for that commit,
+`verify-release`, the cua.ai check and the staged rollout. `electron_dry_run`,
+`sparkle_electron`, `skip_staging_gate` and `platforms` are refused. Its
+Sigstore identity is the workflow at `refs/heads/main`, which the installers
+accept for the app next to the usual tag identity.
diff --git a/scripts/install/install.ps1 b/scripts/install/install.ps1
index 805b22989a..1df7bf2bfb 100644
--- a/scripts/install/install.ps1
+++ b/scripts/install/install.ps1
@@ -477,15 +477,19 @@ function Find-Artifact($Manifest, [string]$Component, [string]$Platform, [string
return $hit[0]
}
-# The exact Sigstore identity that must have signed a manifest entry: the CLI
-# by cd-cua-sdk.yml at refs/tags/cua-sdk-v<version>, the app by
-# cd-cua-spaces.yml at refs/tags/cua-spaces-v<version>.
+# The exact Sigstore identities, one of which must have signed a manifest
+# entry: the CLI by cd-cua-sdk.yml at refs/tags/cua-sdk-v<version>, the app by
+# cd-cua-spaces.yml at refs/tags/cua-spaces-v<version>, or at refs/heads/main
+# for a release rebuilt from main (rebuild_tag; only a run that passed every
+# release gate signs).
function Get-CosignIdentity($Entry) {
$v = [string]$Entry.version
if ($v -notmatch '^[0-9A-Za-z.+-]+$') { return $null }
switch ([string]$Entry.component) {
- 'cli' { return "https://github.com/$Repo/.github/workflows/cd-cua-sdk.yml@refs/tags/cua-sdk-v$v" }
- 'app' { return "https://github.com/$Repo/.github/workflows/cd-cua-spaces.yml@refs/tags/cua-spaces-v$v" }
+ 'cli' { return @("https://github.com/$Repo/.github/workflows/cd-cua-sdk.yml@refs/tags/cua-sdk-v$v") }
+ 'app' { return @(
+ "https://github.com/$Repo/.github/workflows/cd-cua-spaces.yml@refs/tags/cua-spaces-v$v",
+ "https://github.com/$Repo/.github/workflows/cd-cua-spaces.yml@refs/heads/main") }
default { return $null }
}
}
@@ -502,12 +506,16 @@ function Test-Signature([string]$File, $Entry, [string]$ManifestUrl) {
$cosign = Get-Command cosign -ErrorAction SilentlyContinue
if (-not $ok -and $Entry.PSObject.Properties['cosign_bundle'] -and $cosign) {
Get-Remote (Resolve-ArtifactUrl $Entry.cosign_bundle $ManifestUrl) "$File.sigstore.json" $ManifestUrl
- $identity = Get-CosignIdentity $Entry
- if (-not $identity) { Stop-Install "no release identity for $(Split-Path -Leaf $File) in the manifest" }
- & $cosign.Source verify-blob --bundle "$File.sigstore.json" `
- --certificate-identity $identity `
- --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' $File *> $null
- if ($LASTEXITCODE -ne 0) { Stop-Install "cosign signature check failed for $(Split-Path -Leaf $File)" }
+ $identities = Get-CosignIdentity $Entry
+ if (-not $identities) { Stop-Install "no release identity for $(Split-Path -Leaf $File) in the manifest" }
+ $verified = $false
+ foreach ($identity in $identities) {
+ & $cosign.Source verify-blob --bundle "$File.sigstore.json" `
+ --certificate-identity $identity `
+ --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' $File *> $null
+ if ($LASTEXITCODE -eq 0) { $verified = $true; break }
+ }
+ if (-not $verified) { Stop-Install "cosign signature check failed for $(Split-Path -Leaf $File)" }
$ok = $true
}
if (-not $ok -and $RequireSignature) {
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index ae4e0806ce..4ec0fb288f 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -79,7 +79,8 @@ LATEST_TAG="cua-install-latest"
MINISIGN_PUBKEY="${CUA_INSTALL_MINISIGN_PUBKEY:-}"
# Only the release workflows may sign, each at its own release tag: the CLI
# by cd-cua-sdk.yml at refs/tags/cua-sdk-v<version>, the app by
-# cd-cua-spaces.yml at refs/tags/cua-spaces-v<version> (cosign_identity).
+# cd-cua-spaces.yml at refs/tags/cua-spaces-v<version>, or at refs/heads/main for
+# a release rebuilt from main (cosign_identity).
COSIGN_ISSUER="https://token.actions.githubusercontent.com"
want_cli=1
@@ -895,8 +896,11 @@ resolve_url() {
esac
}
-# cosign_identity ENTRY: the exact Sigstore certificate identity (workflow
-# at its release tag) that must have signed this manifest entry's artifact.
+# cosign_identity ENTRY: the exact Sigstore certificate identities (workflow
+# at its release tag), one per line, one of which must have signed this
+# manifest entry's artifact. The app also accepts cd-cua-spaces.yml at
+# refs/heads/main: a release rebuilt by a dispatch from main (rebuild_tag)
+# is signed by that run, and only a run that passed every release gate signs.
cosign_identity() {
c="$(json_field "$1" component)"
v="$(json_field "$1" version)"
@@ -905,7 +909,10 @@ cosign_identity() {
esac
case "$c" in
cli) printf 'https://github.com/%s/.github/workflows/cd-cua-sdk.yml@refs/tags/cua-sdk-v%s\n' "$REPO" "$v" ;;
- app) printf 'https://github.com/%s/.github/workflows/cd-cua-spaces.yml@refs/tags/cua-spaces-v%s\n' "$REPO" "$v" ;;
+ app)
+ printf 'https://github.com/%s/.github/workflows/cd-cua-spaces.yml@refs/tags/cua-spaces-v%s\n' "$REPO" "$v"
+ printf 'https://github.com/%s/.github/workflows/cd-cua-spaces.yml@refs/heads/main\n' "$REPO"
+ ;;
*) return 1 ;;
esac
}
@@ -922,12 +929,18 @@ verify_signature() { # file entry
bundle="$(json_field "$2" cosign_bundle)"
if [ "$sig_ok" = 0 ] && [ -n "$bundle" ] && has cosign; then
fetch "$(resolve_url "$bundle")" "$1.sigstore.json"
- identity="$(cosign_identity "$2")" ||
+ identities="$(cosign_identity "$2")" ||
die "no release identity for ${1##*/} in the manifest"
- cosign verify-blob --bundle "$1.sigstore.json" \
- --certificate-identity "$identity" \
- --certificate-oidc-issuer "$COSIGN_ISSUER" "$1" >/dev/null 2>&1 ||
- die "cosign signature check failed for ${1##*/}"
+ cosign_ok=0
+ for identity in $identities; do
+ if cosign verify-blob --bundle "$1.sigstore.json" \
+ --certificate-identity "$identity" \
+ --certificate-oidc-issuer "$COSIGN_ISSUER" "$1" >/dev/null 2>&1; then
+ cosign_ok=1
+ break
+ fi
+ done
+ [ "$cosign_ok" = 1 ] || die "cosign signature check failed for ${1##*/}"
sig_ok=1
fi
if [ "$sig_ok" = 0 ] && [ "$require_sig" = 1 ]; then
diff --git a/scripts/install/tests/run.sh b/scripts/install/tests/run.sh
index ad50c82bda..6d1aea8faf 100755
--- a/scripts/install/tests/run.sh
+++ b/scripts/install/tests/run.sh
@@ -578,6 +578,36 @@ inst CUA_INSTALL_MANIFEST_URL="$base/sig2/release-artifacts.json" -- --yes --no-
check "unverifiable signatures, default output: plain checksum line only" sh -c "[ $status = 0 ] && grep -q '(downloads checked)' '$work/out' && ! grep -qi 'cosign\|minisign\|signatures were not\|checksum' '$work/out'"
inst CUA_INSTALL_MANIFEST_URL="$base/sig2/release-artifacts.json" -- --yes --no-onboarding --select spaces --require-signature --prefix "$work/sg2"
check "--require-signature still fails without minisign or cosign" sh -c "[ $status != 0 ] && grep -q 'no verifiable signature' '$work/out'"
+
+# cosign, app: a release rebuilt by a dispatch from main is signed by
+# cd-cua-spaces.yml at refs/heads/main; the installer accepts that identity
+# next to the tag one, and still refuses any other.
+sig3="$release/sig3"
+mkdir -p "$sig3" "$work/fakebin-cosign3"
+cp "$tag_dir"/cua-cli-* "$tag_dir"/cua-spaces-"$version"-linux-x64.AppImage "$sig3/"
+for f in "$sig3"/cua-cli-*.tar.gz "$sig3"/*.AppImage; do printf '{}\n' >"$f.sigstore.json"; done
+python3 "$manifest_tool" --component cli --version "$version" --dir "$sig3" --out "$sig3/cli.json"
+python3 "$manifest_tool" --component app --version "$version" --dir "$sig3" --merge "$sig3/cli.json" --out "$sig3/release-artifacts.json"
+cli_identity="https://github.com/trycua/cua/.github/workflows/cd-cua-sdk.yml@refs/tags/cua-sdk-v$version"
+main_identity="https://github.com/trycua/cua/.github/workflows/cd-cua-spaces.yml@refs/heads/main"
+cat >"$work/fakebin-cosign3/cosign" <<COSIGN
+#!/bin/sh
+prev=""
+for a in "\$@"; do
+ if [ "\$prev" = --certificate-identity ]; then
+ [ "\$a" = "$cli_identity" ] && exit 0
+ [ "\$a" = "$main_identity" ] && exit 0
+ fi
+ prev="\$a"
+done
+exit 1
+COSIGN
+chmod +x "$work/fakebin-cosign3/cosign"
+inst PATH="$work/fakebin-cosign3:$PATH" CUA_INSTALL_MANIFEST_URL="$base/sig3/release-artifacts.json" -- --yes --no-onboarding --select spaces --require-signature --prefix "$work/sg4"
+check "cosign accepts the app signed by cd-cua-spaces.yml at refs/heads/main (rebuilt release)" sh -c "[ $status = 0 ] && [ -x '$work/sg4/bin/cua-spaces' ]"
+printf '#!/bin/sh\nexit 1\n' >"$work/fakebin-cosign3/cosign"
+inst PATH="$work/fakebin-cosign3:$PATH" CUA_INSTALL_MANIFEST_URL="$base/sig3/release-artifacts.json" -- --yes --no-onboarding --select spaces --prefix "$work/sg5"
+check "cosign: an app bundle from any other identity aborts" sh -c "[ $status != 0 ] && grep -q 'cosign signature check failed' '$work/out'"
# Upgrade over a running older daemon: the new cua stops it (never a broad
# kill) and starts the new one. A fake old cua reports a running 0.0.9 daemon.
mkdir -p "$work/up/bin"