Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
- name: No generated or machine-specific files are tracked
run: scripts/check-tracked-artifacts.sh

# Every discovered package (Cargo, npm, PyPI, pub.dev) carries the
# workspace version, internal ranges accept it, lockfiles agree, and
# release.yml publishes each publishable package. Node built-ins only.
- name: Release versions are consistent
run: node scripts/check-versions.mjs

# ---------------------------------------------------------------------------
# Published benchmarks — schema, deterministic graphic, links, documented
# commands. Runs no benchmark (those are manual: public-benchmarks.yml).
Expand Down
210 changes: 193 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ name: Release
on:
push:
tags: ["v*.*.*"]
# Release dry run on a branch (run it on main before tagging): the whole
# verify phase on that commit, plus the credentials preflight below. Every
# publish job runs only for a version tag, so a dispatch publishes nothing.
workflow_dispatch:

# Never let two releases run against each other.
concurrency:
Expand All @@ -46,6 +50,20 @@ jobs:
with:
node-version: 22

# The tag must name the version the manifests already carry. The npm
# jobs set their version from the tag, but the wheels, the pub.dev
# package and the server binary are built from the manifests, so a tag
# that disagrees would publish mixed versions.
- name: Tag matches every release manifest
run: |
set -euo pipefail
node scripts/check-versions.mjs
WS="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml)"
if [ "${{ github.ref_type }}" = tag ] && [ "v$WS" != "${{ github.ref_name }}" ]; then
echo "Error: tag ${{ github.ref_name }} but the manifests are at $WS (scripts/bump-version.sh)."
exit 1
fi

- name: CLI — tests
working-directory: cli
run: node --test
Expand Down Expand Up @@ -295,11 +313,9 @@ jobs:
run: dart pub publish --dry-run

# Python wheels (sdks/python): abi3, one per platform for CPython 3.11+.
# VERIFY ONLY: the wheels are built (and, where the runner can run them,
# tested) and uploaded as workflow artifacts. There is no PyPI publish job
# yet, and this job is deliberately not in the publish jobs' `needs` until
# the Python SDK is released: a wheel failure must not block the npm,
# pub.dev and image releases before then.
# Built (and, where the runner can run them, tested) here; checked together
# in verify-python; published to PyPI by publish-pypi. Every publish job
# needs verify-python, so a broken wheel stops the whole release.
build-python:
name: Verify — Python wheel ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -359,6 +375,38 @@ jobs:
path: sdks/python/dist/*.whl
if-no-files-found: error

# All five wheels together: one per platform, the tag's version, and each
# passing the package check (tags, metadata, contents, RECORD hashes,
# version consistency) and `twine check`.
verify-python:
name: Verify — Python distribution
needs: [build-python]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: actions/setup-python@v6
with:
python-version: "3.11"

- uses: actions/download-artifact@v7
with:
pattern: python-wheel-*
merge-multiple: true
path: dist

- name: Check the wheels
run: |
set -euo pipefail
# verify-js checked that a tag equals this version.
VERSION="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml)"
ls -l dist
COUNT=$(ls dist/checkgate-"$VERSION"-*.whl | wc -l)
if [ "$COUNT" -ne 5 ]; then echo "Error: expected 5 wheels for $VERSION, found $COUNT."; exit 1; fi
python scripts/check-python-package.py dist --version "$VERSION"
python -m pip install "twine>=6.1,<7"
python -m twine check --strict dist/*.whl

# Build the image without pushing, so a broken or vulnerable image blocks the
# release instead of being discovered after the npm packages are already live.
build-docker:
Expand Down Expand Up @@ -402,13 +450,101 @@ jobs:
vuln-type: 'os,library'
severity: 'CRITICAL'

# Credentials preflight (workflow_dispatch only). Proves, without
# publishing, what the tag run will need: an npm identity that can publish
# in the @checkgate scope, parseable pub.dev credentials, and a PyPI trusted
# publisher matching this workflow and environment. Prints no secret.
#
# The PyPI check exchanges this job's OIDC token for a short-lived upload
# token (discarded unused), exactly as publish-pypi will. If the publisher
# is still *pending* (project not yet on PyPI), that exchange creates the
# empty project `checkgate` under the account that registered it.
preflight-credentials:
name: Preflight — publishing credentials
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/checkgate/
permissions:
contents: read
id-token: write
steps:
- uses: actions/setup-node@v5
with:
node-version: 22
registry-url: https://registry.npmjs.org

- name: npm — identity and @checkgate scope access
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -euo pipefail
[ -n "$NODE_AUTH_TOKEN" ] || { echo "Error: NPM_TOKEN is not set."; exit 1; }
WHO="$(npm whoami)"
echo "npm identity: $WHO"
npm access list packages --json > access.json
node -e '
const a = require("./access.json");
const need = ["node","web","cli","edge","ssr","react-native"].map((p) => "@checkgate/" + p);
const bad = need.filter((p) => a[p] !== "read-write");
for (const p of need) console.log(` ${p}: ${a[p] ?? "no access"}`);
if (bad.length) { console.error("Error: no read-write access to " + bad.join(", ")); process.exit(1); }
'
# The new packages (openfeature-provider, node-integrations,
# mcp-server) are created by their first publish. Org members of
# any role may create packages in the org scope; a granular token
# must also cover the @checkgate scope, not only listed packages.
if npm org ls checkgate "$WHO" --json > role.json 2>/dev/null; then
echo "role in the checkgate org: $(node -p 'Object.values(require("./role.json"))[0] ?? "none"')"
else
echo "::warning::Could not read the checkgate org role (the token may lack organization read permission). Confirm on npmjs.com that this token's package scope includes @checkgate."
fi
for p in openfeature-provider node-integrations mcp-server; do
if npm view "@checkgate/$p" version >/dev/null 2>&1; then
echo " @checkgate/$p already exists: $(npm view @checkgate/$p versions --json | tr -d '\n ')"
else
echo " @checkgate/$p does not exist yet (its first publish creates it)"
fi
done

- name: pub.dev — credentials present and well-formed
env:
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
run: |
set -euo pipefail
[ -n "$PUB_CREDENTIALS" ] || { echo "Error: PUB_CREDENTIALS is not set."; exit 1; }
printf '%s' "$PUB_CREDENTIALS" | node -e '
let b = ""; process.stdin.on("data", (d) => b += d).on("end", () => {
const c = JSON.parse(b);
if (!c.refreshToken) { console.error("Error: PUB_CREDENTIALS has no refreshToken"); process.exit(1); }
console.log("pub.dev credentials: refresh token present");
});'

- name: PyPI — trusted publisher accepts this workflow
run: |
set -euo pipefail
AUD="$(curl -fsS https://pypi.org/_/oidc/audience | node -p 'JSON.parse(require("fs").readFileSync(0)).audience')"
OIDC="$(curl -fsS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$AUD" | node -p 'JSON.parse(require("fs").readFileSync(0)).value')"
echo "::add-mask::$OIDC"
RESP="$(curl -sS -X POST https://pypi.org/_/oidc/mint-token -H 'Content-Type: application/json' -d "{\"token\":\"$OIDC\"}")"
printf '%s' "$RESP" | node -e '
const r = JSON.parse(require("fs").readFileSync(0));
if (r.success && r.token) { console.log("PyPI trusted publishing: accepted (upload token minted and discarded)"); process.exit(0); }
console.error("Error: PyPI refused the trusted-publishing exchange:");
console.error(JSON.stringify({ message: r.message, errors: (r.errors || []).map((e) => e.code + ": " + e.description) }, null, 2));
process.exit(1);
'
echo "PyPI project page: $(curl -s -o /dev/null -w '%{http_code}' https://pypi.org/pypi/checkgate/json)"

# ===========================================================================
# PHASE 2 — PUBLISH. Every job below waits for *all* of phase 1.
# ===========================================================================

publish-node:
name: Publish — @checkgate/node
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -477,7 +613,8 @@ jobs:

publish-web:
name: Publish — @checkgate/web
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -523,7 +660,8 @@ jobs:

publish-cli:
name: Publish — @checkgate/cli
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -550,7 +688,8 @@ jobs:

publish-edge:
name: Publish — @checkgate/edge
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -577,7 +716,8 @@ jobs:

publish-ssr:
name: Publish — @checkgate/ssr
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -604,7 +744,8 @@ jobs:

publish-openfeature:
name: Publish — @checkgate/openfeature-provider
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -631,7 +772,8 @@ jobs:

publish-node-integrations:
name: Publish — @checkgate/node-integrations
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -658,7 +800,8 @@ jobs:

publish-mcp-server:
name: Publish — @checkgate/mcp-server
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -685,7 +828,8 @@ jobs:

publish-react-native:
name: Publish — @checkgate/react-native
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -716,7 +860,8 @@ jobs:

publish-flutter:
name: Publish — checkgate_flutter (pub.dev)
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
id-token: write
Expand Down Expand Up @@ -756,7 +901,8 @@ jobs:

publish-docker:
name: Publish — Docker image
needs: [verify-js, build-native, build-web, verify-flutter, build-docker]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -808,11 +954,39 @@ jobs:
run: |
cosign sign --yes ${{ env.IMAGE_NAME }}@${{ steps.build-push.outputs.digest }}

# PyPI trusted publishing (OIDC): no stored token. Needs, once, on PyPI: a
# publisher for project `checkgate`, owner checkgate-sh, repository
# checkgate, workflow release.yml, environment `pypi`. The action attaches
# PEP 740 attestations to each file.
publish-pypi:
name: Publish — checkgate (PyPI)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/checkgate/
permissions:
contents: read
id-token: write # OIDC token for PyPI trusted publishing and attestations
steps:
- uses: actions/download-artifact@v7
with:
pattern: python-wheel-*
merge-multiple: true
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist

# ===========================================================================
# Final status — one green check that means "the whole release succeeded".
# ===========================================================================
release-complete:
name: Release complete
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- publish-node
- publish-web
Expand All @@ -825,11 +999,13 @@ jobs:
- publish-react-native
- publish-flutter
- publish-docker
- publish-pypi
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "All packages published for ${{ github.ref_name }}:" >> $GITHUB_STEP_SUMMARY
echo "- npm: @checkgate/{node,web,cli,edge,ssr,react-native}" >> $GITHUB_STEP_SUMMARY
echo "- npm: @checkgate/{node,web,cli,edge,ssr,react-native,openfeature-provider,node-integrations,mcp-server}" >> $GITHUB_STEP_SUMMARY
echo "- pub.dev: checkgate_flutter" >> $GITHUB_STEP_SUMMARY
echo "- PyPI: checkgate" >> $GITHUB_STEP_SUMMARY
echo "- ghcr.io: ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
Loading
Loading