Multiplayer agent harness for work.
feat: let the release pick its own version
Josh Francefdad55eebd59
diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.ymlindex e72eb56e0..b2788308f 100644--- a/.github/workflows/publish-cli.yml+++ b/.github/workflows/publish-cli.yml@@ -7,6 +7,10 @@ on:description: Commit SHA whose published images the package should pinrequired: falsetype: string+ version:+ description: Version to publish, overriding cli/package.json+ required: false+ type: stringoutputs:manifest:description: The image manifest the published package pins@@ -16,6 +20,9 @@ on:images_ref:description: Commit SHA whose published images the package should pinrequired: false+ version:+ description: Version to publish, overriding cli/package.json+ required: falsepermissions:contents: read@@ -77,8 +84,14 @@ jobs:printf 'manifest=%s\n' "$(jq -c . cli/manifest.json)" >> "$GITHUB_OUTPUT"- name: Publishworking-directory: cli+ env:+ VERSION: ${{ inputs.version }}+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}run: |set -euo pipefail+ if [ -n "$VERSION" ]; then+ npm version "$VERSION" --no-git-tag-version --allow-same-version > /dev/null+ fiversion=$(jq -r .version package.json)if npm view "@yc-software/qm@$version" version > /dev/null 2>&1; thenpublished=$(mktemp -d)@@ -95,5 +108,3 @@ jobs:if [ "$version" = 0.1.5 ]; thennpm deprecate @yc-software/[email protected] "Published with an incorrect version number; use 0.1.5."fi- env:- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 671a88f7b..6a70e14d4 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -15,6 +15,7 @@ jobs:contents: readoutputs:tag: ${{ steps.version.outputs.tag }}+ version: ${{ steps.version.outputs.version }}steps:- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfdwith:@@ -29,17 +30,27 @@ jobs:echo "releases are cut from main; this run is on $GITHUB_REF" >&2exit 1fi- version=$(jq -r .version cli/package.json)- case "$version" in+ pkg=$(jq -r .version cli/package.json)+ case "$pkg" in[0-9]*.[0-9]*.[0-9]*) ;;- *) echo "cli/package.json version must be semver, got $version" >&2; exit 1 ;;+ *) echo "cli/package.json version must be semver, got $pkg" >&2; exit 1 ;;esac+ tagged=$(gh api --paginate "repos/$GITHUB_REPOSITORY/git/matching-refs/tags/v" -q '.[].ref' \+ | sed 's|^refs/tags/||' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -1 || true)+ published=$(npm view @yc-software/qm version 2>/dev/null || true)+ base=$(printf '%s\n%s\n' "${tagged:-0.0.0}" "${published:-0.0.0}" | sort -V | tail -1)+ if [ "$(printf '%s\n%s\n' "$base" "$pkg" | sort -V | tail -1)" = "$pkg" ] && [ "$pkg" != "$base" ]; then+ version=$pkg+ else+ IFS=. read -r major minor patch <<< "$base"+ version="$major.$minor.$((patch + 1))"+ fitag="v$version"if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" > /dev/null 2>&1; then- echo "$tag is already released; bump cli/package.json before releasing again" >&2+ echo "$tag already exists; refusing to move it" >&2exit 1fi- printf 'tag=%s\n' "$tag" >> "$GITHUB_OUTPUT"+ printf 'tag=%s\nversion=%s\n' "$tag" "$version" >> "$GITHUB_OUTPUT"images:name: Images@@ -52,12 +63,16 @@ jobs:cli:name: CLI- needs: images+ needs:+ - preflight+ - imagespermissions:contents: readid-token: writesecrets: inherituses: ./.github/workflows/publish-cli.yml+ with:+ version: ${{ needs.preflight.outputs.version }}release:name: Tag and publish the releasediff --git a/cli/README.md b/cli/README.mdindex ef4c285a6..b95eb5648 100644--- a/cli/README.md+++ b/cli/README.md@@ -22,9 +22,9 @@ This package is published to npm as `@yc-software/qm`, with npm provenance attesbuilding workflow. A release is one dispatch of `.github/workflows/release.yml` from`main`: it signs and pushes the first-party images, publishes the package pinning theirdigests, and then tags `v<version>` and creates the GitHub release with the resolved-digests attached. The version comes from `cli/package.json`, bumped in a PR before dispatching a release-rather than by every pull request that touches the package; a tag that already exists-stops the release rather than moving. The checked-in image manifest is a sentinel that+digests attached. Each release picks its own version: a patch bump past the latest released version, or+`cli/package.json`'s version when a PR raised it higher (for a minor or major bump); a+tag that already exists stops the release rather than moving. The checked-in image manifest is a sentinel thata deployment overrides with real digests. The packed-artifact test exercises the consumerpath locally.diff --git a/test/release-workflows.test.ts b/test/release-workflows.test.tsindex 39dd32ed5..c026ad3cc 100644--- a/test/release-workflows.test.ts+++ b/test/release-workflows.test.ts@@ -126,18 +126,24 @@ test("one dispatchable workflow drives the whole release, main-only and in orderworkflow,/^ {2}images:\n[\s\S]*?needs: preflight\n[\s\S]*?uses: \.\/\.github\/workflows\/release-package\.yml$/m,);- assert.match(workflow, /^ {2}cli:\n[\s\S]*?needs: images\n[\s\S]*?uses: \.\/\.github\/workflows\/publish-cli\.yml$/m);+ assert.match(+ workflow,+ /^ {2}cli:\n[\s\S]*?needs:\n {6}- preflight\n {6}- images\n[\s\S]*?uses: \.\/\.github\/workflows\/publish-cli\.yml\n {4}with:\n {6}version: \$\{\{ needs\.preflight\.outputs\.version \}\}$/m,+ );assert.match(workflow, /^ {2}release:\n[\s\S]*?needs:\n {6}- preflight\n {6}- cli$/m);assert.match(workflow, /concurrency:\n {2}group: release\n {2}cancel-in-progress: false/);});-test("the release refuses a tag it already published and writes the tag last", () => {+test("the release bumps its own version past everything already released", () => {const workflow = readFileSync(".github/workflows/release.yml", "utf8");- assert.match(workflow, /version=\$\(jq -r \.version cli\/package\.json\)/);+ assert.match(workflow, /pkg=\$\(jq -r \.version cli\/package\.json\)/);assert.match(workflow, /cli\/package\.json version must be semver/);+ assert.match(workflow, /matching-refs\/tags\/v/);+ assert.match(workflow, /npm view @yc-software\/qm version/);+ assert.match(workflow, /version="\$major\.\$minor\.\$\(\(patch \+ 1\)\)"/);assert.match(workflow, /tag="v\$version"/);- assert.match(workflow, /is already released; bump cli\/package\.json before releasing again/);+ assert.match(workflow, /already exists; refusing to move it/);assert.ok(workflow.indexOf("already released") < workflow.indexOf("gh release create"),"the tag gate runs before anything is published",