Files
DeepSeek-TUI/.github/workflows/release.yml
CodeWhale Bot f9519454ca fix(ci): close the CodeQL cache-poisoning Highs in the release workflows
All 19 open actions/cache-poisoning/poisonable-step alerts (#88-#106) sit in
release.yml, release-candidate.yml and release-artifacts.yml: jobs interpolated
the caller SHA into ref/caches and let setup-node's implicit npm cache key on
run identity. Now caller source_sha is pinned against github.sha by a pin job
(refusing any retarget), checkout and build identity use GITHUB_SHA through
env indirection instead of template interpolation, rust-cache keys use stable
prefix-key values, and setup-node's implicit package cache is off where it
cannot be keyed safely.

Also carries the CodeQL #107 fix from the same lane: catalog_models_dev.py
prints remote limit values as numbers/null/redacted only and drops query and
fragment material from source URLs before logging.

Harvested from #5401 (workflow+script files; CHANGELOG edit intentionally
excluded here and lands with the release branch; GHSA advisory text split to
a later PR as advised).

No-Issue: CodeQL alert remediation (alerts #88-#107); no single user-facing issue tracks these

Signed-off-by: Hunter Bown <hunter@hmbown.com>
2026-08-16 22:52:15 -07:00

564 lines
22 KiB
YAML

name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
version:
description: 'Release version, without v; dispatch from the matching existing vX.Y.Z tag ref'
required: true
type: string
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Dwarnings
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release.outputs.tag }}
sha: ${{ steps.release.outputs.sha }}
version: ${{ steps.release.outputs.version }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
- name: Resolve release source
id: release
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
if ! [[ "${INPUT_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Release version '${INPUT_VERSION}' must use X.Y.Z." >&2
exit 1
fi
tag="v${INPUT_VERSION}"
if [[ "${GITHUB_REF}" != "refs/tags/${tag}" ]]; then
echo "::error::Dispatch release.yml from --ref ${tag}, not ${GITHUB_REF}." >&2
exit 1
fi
else
tag="${GITHUB_REF_NAME}"
fi
if ! [[ "${tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Release tag '${tag}' must use vX.Y.Z." >&2
exit 1
fi
if ! git rev-parse --verify "refs/tags/${tag}^{commit}" >/dev/null 2>&1; then
echo "::error::Release tag ${tag} does not exist. Create it from the frozen main commit before dispatching." >&2
exit 1
fi
sha="$(git rev-parse "refs/tags/${tag}^{commit}")"
event_sha="$(git rev-parse "${GITHUB_SHA}^{commit}")"
if [[ "${event_sha}" != "${sha}" ]]; then
echo "::error::Trigger SHA ${event_sha} does not match ${tag} at ${sha}; the tag moved after this run was created." >&2
exit 1
fi
{
echo "tag=${tag}"
echo "sha=${sha}"
echo "version=${tag#v}"
} >> "${GITHUB_OUTPUT}"
- name: Validate tagged release metadata
shell: bash
env:
SHA: ${{ steps.release.outputs.sha }}
TAG: ${{ steps.release.outputs.tag }}
run: |
set -euo pipefail
git checkout --detach "${SHA}"
expected="${TAG#v}"
workspace_version="$(grep -E '^version = "' Cargo.toml | head -n1 | sed -E 's/^version = "([^"]+)".*/\1/')"
npm_version="$(node -p "require('./npm/codewhale/package.json').version")"
binary_version="$(node -p "require('./npm/codewhale/package.json').codewhaleBinaryVersion")"
sdk_version="$(node -p "require('./npm/runtime-sdk/package.json').version")"
vscode_version="$(node -p "require('./extensions/vscode/package.json').version")"
for pair in \
"workspace:${workspace_version}" \
"npm:${npm_version}" \
"npm binary:${binary_version}" \
"runtime-sdk:${sdk_version}" \
"vscode:${vscode_version}"; do
label="${pair%%:*}"
actual="${pair#*:}"
if [[ "${actual}" != "${expected}" ]]; then
echo "::error::${label} version ${actual} does not match tag ${TAG}." >&2
exit 1
fi
done
./scripts/release/check-versions.sh --require-dated-release
- name: Require release source on main
run: ./scripts/release/ensure-release-on-main.sh "${{ steps.release.outputs.sha }}"
- name: Refuse an existing public asset set
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.release.outputs.tag }}
run: node scripts/release/ensure-release-assets-absent.js "${GITHUB_REPOSITORY}" "${TAG}"
parity:
needs: resolve
runs-on: ubuntu-latest
steps:
# resolve already proved GITHUB_SHA equals the tag commit. Do not
# interpolate needs.resolve.outputs.sha into checkout or cache keys —
# CodeQL treats a *sha* ref as an untrusted checkout on workflow_dispatch
# (default-branch cache write).
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master 2026-07-18
with:
toolchain: stable
components: clippy, rustfmt
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
id: sccache
continue-on-error: true
- name: Enable sccache
if: steps.sccache.outcome == 'success'
shell: bash
run: |
{
echo "SCCACHE_GHA_ENABLED=true"
echo "RUSTC_WRAPPER=sccache"
echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1"
} >> "${GITHUB_ENV}"
- name: Install Linux system dependencies
run: |
for i in 1 2 3 4 5; do
sudo apt-get update && break
echo "apt-get update failed (attempt $i); retrying in 15s"
sleep 15
done
sudo apt-get install -y libdbus-1-dev pkg-config
# Restore after the trusted lockfile is on disk. Key is OS + arch +
# explicit stable toolchain + rust-cache's Cargo.lock / rust-toolchain
# hash. Never interpolate github.event, github.ref, github.sha, or inputs.
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
cache-bin: false
prefix-key: v1-${{ runner.os }}-${{ runner.arch }}-stable
- name: Format check
run: cargo fmt --all -- --check
- name: Compile check
run: cargo check --workspace --all-targets --locked
- name: OHOS dependency graph
run: ./scripts/release/check-ohos-deps.sh
- name: Clippy
run: |
cargo clippy --workspace --all-targets --all-features --locked -- \
-D warnings \
-A clippy::uninlined_format_args \
-A clippy::too_many_arguments \
-A clippy::unnecessary_map_or \
-A clippy::collapsible_if \
-A clippy::assertions_on_constants
- name: Workspace tests
run: cargo test --workspace --all-features --locked
env:
# Match the CI test lane: test threads get the same stack the product
# gives itself (main.rs CODEWHALE_MAIN_STACK_BYTES). See the note in
# ci.yml's "Run tests" step. Without it this gate runs the deep
# engine/runtime futures on a stack that never ships.
RUST_MIN_STACK: '16777216'
- name: Protocol schema parity
run: cargo test -p codewhale-protocol --test parity_protocol --locked
- name: State persistence parity
run: cargo test -p codewhale-state --test parity_state --locked
- name: Lockfile drift guard
run: git diff --exit-code -- Cargo.lock
artifacts:
needs: [parity, resolve]
if: ${{ !cancelled() && needs.resolve.result == 'success' && needs.parity.result == 'success' }}
uses: ./.github/workflows/release-artifacts.yml
with:
source_sha: ${{ needs.resolve.outputs.sha }}
version: ${{ needs.resolve.outputs.version }}
retention_days: 14
docker-build:
needs: [artifacts, resolve]
if: ${{ !cancelled() && needs.artifacts.result == 'success' }}
name: Docker ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
architecture: amd64
cli_artifact: codewhale-linux-x64
shim_artifact: codew-linux-x64
- runner: ubuntu-24.04-arm
platform: linux/arm64
architecture: arm64
cli_artifact: codewhale-linux-arm64
shim_artifact: codew-linux-arm64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- name: Checkout release infrastructure
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: ${{ needs.resolve.outputs.sha }}
path: infra
- name: Download Codewhale release binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: ${{ matrix.cli_artifact }}
path: docker-context/bin
- name: Download codew release alias
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: ${{ matrix.shim_artifact }}
path: docker-context/bin
- name: Verify native release bytes
shell: bash
env:
CLI_ARTIFACT: ${{ matrix.cli_artifact }}
SHIM_ARTIFACT: ${{ matrix.shim_artifact }}
run: |
set -euo pipefail
mv -- "docker-context/bin/${CLI_ARTIFACT}" docker-context/bin/codewhale
mv -- "docker-context/bin/${SHIM_ARTIFACT}" docker-context/bin/codew
chmod 0755 docker-context/bin/codewhale docker-context/bin/codew
cmp docker-context/bin/codewhale docker-context/bin/codew
docker-context/bin/codewhale --version
docker-context/bin/codew --version
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Normalize image name
id: image
shell: bash
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Extract image labels
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: |
${{ steps.image.outputs.name }}
tags: |
type=raw,value=${{ needs.resolve.outputs.version }}
- name: Revalidate release tag before container upload
env:
EXPECTED_SHA: ${{ needs.resolve.outputs.sha }}
TAG: ${{ needs.resolve.outputs.tag }}
run: |
./infra/scripts/release/verify-remote-tag.sh \
"https://github.com/${GITHUB_REPOSITORY}.git" \
"${TAG}" \
"${EXPECTED_SHA}"
- name: Assemble and push native image by digest
id: build
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
env:
DOCKER_BUILD_RECORD_UPLOAD: false
DOCKER_BUILD_SUMMARY: false
with:
context: docker-context
file: infra/packaging/docker/Dockerfile.release
platforms: ${{ matrix.platform }}
provenance: mode=max
sbom: true
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=true
- name: Smoke native image digest
shell: bash
env:
IMAGE: ${{ steps.image.outputs.name }}@${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
docker pull "${IMAGE}"
docker run --rm --entrypoint codewhale "${IMAGE}" --version
docker run --rm --entrypoint codew "${IMAGE}" --version
- name: Export image digest
shell: bash
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
if ! [[ "${DIGEST}" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "Unexpected image digest: ${DIGEST}" >&2
exit 1
fi
mkdir -p digests
touch "digests/${DIGEST#sha256:}"
- name: Upload image digest
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: docker-digest-${{ matrix.architecture }}
path: digests/*
if-no-files-found: error
retention-days: 1
overwrite: true
docker:
needs: [docker-build, resolve]
if: ${{ !cancelled() && needs.docker-build.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout release infrastructure
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: ${{ needs.resolve.outputs.sha }}
path: infra
- name: Download native image digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: digests
pattern: docker-digest-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Normalize image name
id: image
shell: bash
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Extract metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: |
${{ steps.image.outputs.name }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=ref,event=tag
type=semver,pattern={{version}},value=${{ needs.resolve.outputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.resolve.outputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=semver,pattern=v{{major}},value=${{ needs.resolve.outputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=${{ inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=v${{ inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest
- name: Revalidate release tag before container publish
env:
EXPECTED_SHA: ${{ needs.resolve.outputs.sha }}
TAG: ${{ needs.resolve.outputs.tag }}
run: |
./infra/scripts/release/verify-remote-tag.sh \
"https://github.com/${GITHUB_REPOSITORY}.git" \
"${TAG}" \
"${EXPECTED_SHA}"
- name: Publish multi-architecture manifest
shell: bash
env:
IMAGE: ${{ steps.image.outputs.name }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
set -euo pipefail
mapfile -t digest_files < <(find digests -maxdepth 1 -type f -printf '%f\n' | sort)
if [[ "${#digest_files[@]}" -ne 2 ]]; then
echo "Expected exactly two native image digests; found ${#digest_files[@]}." >&2
exit 1
fi
sources=()
for digest in "${digest_files[@]}"; do
if ! [[ "${digest}" =~ ^[0-9a-f]{64}$ ]]; then
echo "Unexpected image digest file: ${digest}" >&2
exit 1
fi
sources+=("${IMAGE}@sha256:${digest}")
done
tag_args=()
while IFS= read -r tag; do
[[ -n "${tag}" ]] && tag_args+=(--tag "${tag}")
done <<< "${TAGS}"
if [[ "${#tag_args[@]}" -eq 0 ]]; then
echo "No container tags were generated." >&2
exit 1
fi
docker buildx imagetools create "${tag_args[@]}" "${sources[@]}"
- name: Verify and smoke published container
shell: bash
env:
IMAGE: ${{ steps.image.outputs.name }}:${{ needs.resolve.outputs.tag }}
run: |
set -euo pipefail
docker buildx imagetools inspect "${IMAGE}"
raw_manifest="$(docker buildx imagetools inspect --raw "${IMAGE}")"
jq -e \
'[.manifests[] | select(.platform.os == "linux") | "linux/\(.platform.architecture)"] | unique | sort == ["linux/amd64", "linux/arm64"]' \
<<< "${raw_manifest}"
docker pull "${IMAGE}"
docker run --rm --entrypoint codewhale "${IMAGE}" --version
docker run --rm --entrypoint codew "${IMAGE}" --version
release:
needs: [artifacts, docker, resolve]
if: ${{ !cancelled() && needs.artifacts.result == 'success' && needs.docker.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: ${{ needs.resolve.outputs.sha }}
path: repo
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 20
package-manager-cache: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: codewhale-release-assets
path: artifacts
- name: Revalidate exact authoritative asset set
run: node repo/scripts/release/assemble-release-assets.js --verify artifacts
- name: Generate release body from CHANGELOG
shell: bash
run: |
./repo/scripts/release/generate-release-body.sh \
"${{ needs.resolve.outputs.tag }}" repo/CHANGELOG.md > release-body.md
- name: Revalidate release tag before GitHub Release write
env:
EXPECTED_SHA: ${{ needs.resolve.outputs.sha }}
TAG: ${{ needs.resolve.outputs.tag }}
run: |
./repo/scripts/release/verify-remote-tag.sh \
"https://github.com/${GITHUB_REPOSITORY}.git" \
"${TAG}" \
"${EXPECTED_SHA}"
- name: Reconfirm public asset set is still empty
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.resolve.outputs.tag }}
run: node repo/scripts/release/ensure-release-assets-absent.js "${GITHUB_REPOSITORY}" "${TAG}"
- uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3
with:
tag_name: ${{ needs.resolve.outputs.tag }}
files: artifacts/*
prerelease: false
body_path: release-body.md
overwrite_files: false
fail_on_unmatched_files: true
npm:
needs: [release, resolve]
if: ${{ !cancelled() && needs.release.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: ${{ needs.resolve.outputs.sha }}
fetch-depth: 0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Pin OIDC-capable npm CLI
run: npm install --global npm@12.0.2
- name: Revalidate release tag before npm publish
env:
EXPECTED_SHA: ${{ needs.resolve.outputs.sha }}
TAG: ${{ needs.resolve.outputs.tag }}
run: |
./scripts/release/verify-remote-tag.sh \
"https://github.com/${GITHUB_REPOSITORY}.git" \
"${TAG}" \
"${EXPECTED_SHA}"
- name: Revalidate public release assets
env:
GH_TOKEN: ${{ github.token }}
run: ./scripts/release/verify-release-assets.sh "${{ needs.resolve.outputs.version }}"
- name: Test npm wrapper
working-directory: npm/codewhale
run: npm test
- name: Publish npm wrapper with trusted publishing
working-directory: npm/codewhale
env:
# npm runs prepublishOnly in this step; that guard revalidates the
# public GitHub Release and therefore needs the same read token as
# the explicit asset gate above.
GH_TOKEN: ${{ github.token }}
run: npm publish --access public
homebrew:
needs: [release, resolve]
if: ${{ !cancelled() && needs.release.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check Homebrew tap token
id: homebrew-token
env:
TOKEN: ${{ secrets.HOMEBREW_TAP_PAT || secrets.RELEASE_TAG_PAT }}
run: |
if [[ -z "${TOKEN:-}" ]]; then
echo "No Homebrew tap token configured; skipping tap update."
echo "available=false" >> "${GITHUB_OUTPUT}"
else
echo "available=true" >> "${GITHUB_OUTPUT}"
fi
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
if: steps.homebrew-token.outputs.available == 'true'
with:
ref: ${{ needs.resolve.outputs.sha }}
- name: Download checksum manifest
if: steps.homebrew-token.outputs.available == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download "${{ needs.resolve.outputs.tag }}" \
--repo "${{ github.repository }}" \
--pattern 'codewhale-artifacts-sha256.txt' \
--dir /tmp
- name: Revalidate release tag before Homebrew tap write
if: steps.homebrew-token.outputs.available == 'true'
env:
EXPECTED_SHA: ${{ needs.resolve.outputs.sha }}
TAG: ${{ needs.resolve.outputs.tag }}
run: |
./scripts/release/verify-remote-tag.sh \
"https://github.com/${GITHUB_REPOSITORY}.git" \
"${TAG}" \
"${EXPECTED_SHA}"
- name: Update Homebrew tap
if: steps.homebrew-token.outputs.available == 'true'
env:
TAG: ${{ needs.resolve.outputs.tag }}
MANIFEST: /tmp/codewhale-artifacts-sha256.txt
TAP_REPO: Hmbown/homebrew-deepseek-tui
TOKEN: ${{ secrets.HOMEBREW_TAP_PAT || secrets.RELEASE_TAG_PAT }}
run: bash .github/scripts/update-homebrew-tap.sh