Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 14:45 UTC
fix(ci): prevent cache poisoning in CLI releases
jkomyno committed
Aug 26, 2026 at 17:21 UTC
b01507591033f37f0ac3d8518ac7415580a689ba
4 files changed
+92
-43
.agents/skills/cli-release/references/release-workflow.md
+5
-6
@@ -27,7 +27,7 @@
27
| --------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------- |
28
| Ship an ordinary CLI change | Merge the reviewed PR to `next` | The push builds a rolling beta automatically. |
29
| Build a beta from a branch | Dispatch `build-beta` at that branch | A prerelease is built from the branch commit. |
30
-| Publish a stable CLI | Promote an existing tested beta | The beta's source commit is rebuilt and published under the stable tag. |
30
+| Publish a stable CLI | Dispatch promotion at an existing tested beta tag | The beta's source commit is rebuilt and published under the stable tag. |
31
| Resume a failed promotion | Re-run or re-dispatch the same beta after inspecting the draft | An unpublished draft can be resumed and its assets replaced. |
32
33
The private CLI `package.json` uses a development sentinel and never selects a
@@ -136,14 +136,13 @@ gh release view "$STABLE_TAG" --repo "$REPOSITORY" --json tagName,isDraft,isPrer
136
- If it is a draft, the promotion can resume it.
137
- If it is already published, stop. Never overwrite a published release.
138
139
-Dispatch the current workflow from `next`; `promote-stable` resolves the source commit from the beta release itself:
139
+Dispatch the workflow at the beta tag. The selected ref supplies the immutable source commit, and the workflow verifies that it matches the beta release before rebuilding:
140
141
```bash
142
gh workflow run build-cli-binaries.yml \
143
--repo "$REPOSITORY" \
144
- --ref next \
145
- --raw-field action=promote-stable \
146
- --raw-field beta_tag="$BETA_TAG"
144
+ --ref "$BETA_TAG" \
145
+ --raw-field action=promote-stable
146
```
147
148
Use the returned URL when available. Otherwise identify the new dispatch, verify its creation time and actor, then watch it:
@@ -153,7 +152,7 @@ gh run list \
152
--repo "$REPOSITORY" \
153
--workflow build-cli-binaries.yml \
154
--event workflow_dispatch \
156
- --branch next \
155
+ --commit "$TARGET_COMMIT" \
156
--limit 5
157
158
gh run watch RUN_ID --repo "$REPOSITORY" --compact --exit-status
.github/scripts/cli-release/resolve-release-target.sh
+24
-19
@@ -5,9 +5,9 @@
5
#
6
# - push to `next` → rolling beta
7
# - workflow_dispatch build-beta [version] → rolling or explicitly versioned beta
8
-# - workflow_dispatch promote-stable <beta tag> → stable promotion
8
+# - workflow_dispatch promote-stable at <beta tag> → stable promotion
9
#
10
-# Inputs (env): EVENT_NAME, ACTION_INPUT, BETA_TAG_INPUT, VERSION_INPUT,
10
+# Inputs (env): EVENT_NAME, ACTION_INPUT, VERSION_INPUT, REF_NAME, REF_TYPE,
11
# GITHUB_TOKEN, REPOSITORY, RUN_NUMBER, COMMIT_SHA
12
# Output: key=value lines appended to $GITHUB_OUTPUT
13
set -euo pipefail
@@ -83,7 +83,6 @@ emit_beta_target() {
83
fi
84
release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"
85
{
86
- echo "checkout_ref=${COMMIT_SHA}"
86
echo "release_name=CLI Beta ${release_tag}"
87
echo "release_tag=${release_tag}"
88
echo "release_version=${next_version}"
@@ -93,9 +92,8 @@ emit_beta_target() {
92
}
93
94
emit_stable_target() {
96
- local release_tag=$1 release_version=$2 checkout_ref=$3
95
+ local release_tag=$1 release_version=$2
96
{
98
- echo "checkout_ref=${checkout_ref}"
97
echo "release_name=CLI ${release_tag}"
98
echo "release_tag=${release_tag}"
99
echo "release_version=${release_version}"
@@ -123,12 +121,22 @@ if [[ "$ACTION_INPUT" != "promote-stable" ]]; then
121
exit 1
122
fi
123
126
-if [[ -z "$BETA_TAG_INPUT" ]]; then
127
- echo "beta_tag input is required for promote-stable" >&2
124
+if [[ "${REF_TYPE:-}" != "tag" ]]; then
125
+ echo "promote-stable must be dispatched at the beta tag with --ref <beta-tag>" >&2
126
exit 1
127
fi
128
131
-encoded_beta_tag=$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["BETA_TAG_INPUT"], safe=""))')
129
+beta_tag=${REF_NAME:-}
130
+
131
+if [[ ! "$beta_tag" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then
132
+ echo "Selected ref must match @composio/cli@<version>-beta.<number>" >&2
133
+ exit 1
134
+fi
135
+
136
+stable_version="${BASH_REMATCH[1]}"
137
+stable_tag="@composio/cli@${stable_version}"
138
+
139
+encoded_beta_tag=$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["REF_NAME"], safe=""))')
140
141
release_json=$(curl -fsSL \
142
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
@@ -137,18 +145,10 @@ release_json=$(curl -fsSL \
145
146
is_prerelease=$(jq -r '.prerelease' <<<"$release_json")
147
if [[ "$is_prerelease" != "true" ]]; then
140
- echo "Release ${BETA_TAG_INPUT} is not a beta prerelease" >&2
141
- exit 1
142
-fi
143
-
144
-if [[ ! "$BETA_TAG_INPUT" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then
145
- echo "Beta tag must match @composio/cli@<version>-beta.<number>" >&2
148
+ echo "Release ${beta_tag} is not a beta prerelease" >&2
149
exit 1
150
fi
151
149
-stable_version="${BASH_REMATCH[1]}"
150
-stable_tag="@composio/cli@${stable_version}"
151
-
152
# Refuse to re-promote an already-PUBLISHED stable release, but allow resuming an
153
# existing DRAFT (a prior promote run that built assets but did not publish). The
154
# REST `/releases/tags/{tag}` endpoint returns 404 for drafts, so use `gh release view`
@@ -164,8 +164,13 @@ fi
164
165
target_commitish=$(jq -r '.target_commitish' <<<"$release_json")
166
if [[ -z "$target_commitish" || "$target_commitish" == "null" ]]; then
167
- echo "Beta release ${BETA_TAG_INPUT} does not expose target_commitish" >&2
167
+ echo "Beta release ${beta_tag} does not expose target_commitish" >&2
168
+ exit 1
169
+fi
170
+
171
+if [[ "$target_commitish" != "$COMMIT_SHA" ]]; then
172
+ echo "Selected beta tag resolves to ${COMMIT_SHA}, but its release targets ${target_commitish}" >&2
173
exit 1
174
fi
175
171
-emit_stable_target "$stable_tag" "$stable_version" "$target_commitish"
176
+emit_stable_target "$stable_tag" "$stable_version"
.github/workflows/build-cli-binaries.yml
+6
-9
@@ -16,15 +16,12 @@ on:
16
workflow_dispatch:
17
inputs:
18
action:
19
- description: 'What to do'
19
+ description: 'What to do (select the beta tag as the workflow ref for promote-stable)'
20
type: choice
21
options:
22
- build-beta
23
- promote-stable
24
default: build-beta
25
- beta_tag:
26
- description: 'Existing beta release tag to promote (only for promote-stable, e.g. @composio/cli@0.2.20-beta.42)'
27
- required: false
25
version:
26
description: 'Optional semver base for a manual beta (e.g. 0.3.0); omit for the next patch after latest stable'
27
required: false
@@ -44,7 +41,6 @@ jobs:
41
name: Resolve Release Metadata
42
runs-on: ubuntu-latest
43
outputs:
47
- checkout_ref: ${{ steps.resolve.outputs.checkout_ref }}
44
release_name: ${{ steps.resolve.outputs.release_name }}
45
release_tag: ${{ steps.resolve.outputs.release_tag }}
46
release_version: ${{ steps.resolve.outputs.release_version }}
@@ -62,8 +58,9 @@ jobs:
58
env:
59
EVENT_NAME: ${{ github.event_name }}
60
ACTION_INPUT: ${{ inputs.action }}
65
- BETA_TAG_INPUT: ${{ inputs.beta_tag }}
61
VERSION_INPUT: ${{ inputs.version }}
62
+ REF_NAME: ${{ github.ref_name }}
63
+ REF_TYPE: ${{ github.ref_type }}
64
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65
REPOSITORY: ${{ github.repository }}
66
RUN_NUMBER: ${{ github.run_number }}
@@ -124,7 +121,7 @@ jobs:
121
- name: Checkout
122
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
123
with:
127
- ref: ${{ needs.prepare.outputs.checkout_ref }}
124
+ ref: ${{ github.sha }}
125
126
- name: Setup Node.js, pnpm, Bun
127
uses: ./.github/actions/setup-node-pnpm-bun
@@ -241,14 +238,14 @@ jobs:
238
RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}
239
PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
240
MAKE_LATEST: ${{ needs.prepare.outputs.make_latest }}
244
- CHECKOUT_REF: ${{ needs.prepare.outputs.checkout_ref }}
241
+ CHECKOUT_REF: ${{ github.sha }}
242
RELEASE_HELPERS_DIR: ${{ github.workspace }}/.release-workflow/.github/scripts/cli-release
243
244
steps:
245
- name: Checkout
246
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
247
with:
251
- ref: ${{ needs.prepare.outputs.checkout_ref }}
248
+ ref: ${{ github.sha }}
249
250
- name: Setup Node.js, pnpm, Bun
251
uses: ./.github/actions/setup-node-pnpm-bun
test/release-workflow.test.ts
+57
-9
@@ -664,6 +664,15 @@ if (!buildCliWorkflow.includes('group: cli-release-${{ needs.prepare.outputs.rel
664
if (!buildCliWorkflow.includes('bash .github/scripts/cli-release/resolve-release-target.sh')) {
665
throw new Error('build-cli-binaries.yml prepare job must delegate to resolve-release-target.sh');
666
}
667
+if (buildCliWorkflow.includes('needs.prepare.outputs.checkout_ref')) {
668
+ throw new Error('CLI release jobs must not execute a ref derived from workflow inputs');
669
+}
670
+if ((buildCliWorkflow.match(/ref: \$\{\{ github\.sha \}\}/g) ?? []).length < 2) {
671
+ throw new Error('CLI build and release jobs must check out the selected workflow commit');
672
+}
673
+if (buildCliWorkflow.includes('beta_tag:')) {
674
+ throw new Error('stable promotion must select the beta through the immutable workflow ref');
675
+}
676
677
// Release archives contain a composio-<target>/ bundle with runtime support files next to the
678
// executable. Both the checked-in guide and the workflow-generated guide must preserve that
@@ -1247,17 +1256,37 @@ function runResolver({ env, releasesFixture, curlFixture, ghViewIsDraft }) {
1256
}
1257
}
1258
1259
+// promote-stable must run at a beta tag, never accept a release candidate through an input.
1260
+{
1261
+ const r = runResolver({
1262
+ env: {
1263
+ EVENT_NAME: 'workflow_dispatch',
1264
+ ACTION_INPUT: 'promote-stable',
1265
+ REF_TYPE: 'branch',
1266
+ REF_NAME: 'next',
1267
+ GITHUB_TOKEN: 'fake-token',
1268
+ REPOSITORY: 'ComposioHQ/composio',
1269
+ RUN_NUMBER: '1',
1270
+ COMMIT_SHA: 'abc123',
1271
+ },
1272
+ });
1273
+ if (r.status === 0 || !r.stderr.includes('must be dispatched at the beta tag')) {
1274
+ throw new Error('promote-stable must reject branch-scoped dispatches');
1275
+ }
1276
+}
1277
+
1278
// promote-stable must REFUSE a tag that is already published (isDraft=false) and emit nothing.
1279
{
1280
const r = runResolver({
1281
env: {
1282
EVENT_NAME: 'workflow_dispatch',
1283
ACTION_INPUT: 'promote-stable',
1256
- BETA_TAG_INPUT: '@composio/cli@0.3.0-beta.5',
1284
+ REF_TYPE: 'tag',
1285
+ REF_NAME: '@composio/cli@0.3.0-beta.5',
1286
GITHUB_TOKEN: 'fake-token',
1287
REPOSITORY: 'ComposioHQ/composio',
1288
RUN_NUMBER: '1',
1260
- COMMIT_SHA: 'unused',
1289
+ COMMIT_SHA: 'abc123',
1290
},
1291
curlFixture: { prerelease: true, target_commitish: 'abc123' },
1292
ghViewIsDraft: 'false',
@@ -1273,17 +1302,18 @@ function runResolver({ env, releasesFixture, curlFixture, ghViewIsDraft }) {
1302
}
1303
}
1304
1276
-// promote-stable happy path: no existing release ⇒ emit a stable target off the beta's commitish.
1305
+// promote-stable happy path: the selected beta tag and release target the same commit.
1306
{
1307
const r = runResolver({
1308
env: {
1309
EVENT_NAME: 'workflow_dispatch',
1310
ACTION_INPUT: 'promote-stable',
1282
- BETA_TAG_INPUT: '@composio/cli@0.3.0-beta.5',
1311
+ REF_TYPE: 'tag',
1312
+ REF_NAME: '@composio/cli@0.3.0-beta.5',
1313
GITHUB_TOKEN: 'fake-token',
1314
REPOSITORY: 'ComposioHQ/composio',
1315
RUN_NUMBER: '1',
1286
- COMMIT_SHA: 'unused',
1316
+ COMMIT_SHA: 'abc123',
1317
},
1318
curlFixture: { prerelease: true, target_commitish: 'abc123' },
1319
// ghViewIsDraft unset ⇒ `gh release view` exits non-zero ⇒ no existing release to refuse.
@@ -1297,10 +1327,28 @@ function runResolver({ env, releasesFixture, curlFixture, ghViewIsDraft }) {
1327
if (r.outputs.prerelease !== 'false' || r.outputs.make_latest !== 'true') {
1328
throw new Error('promote-stable must emit prerelease=false and make_latest=true');
1329
}
1300
- if (r.outputs.checkout_ref !== 'abc123') {
1301
- throw new Error(
1302
- `promote-stable must check out the beta's target_commitish, got ${r.outputs.checkout_ref}`
1303
- );
1330
+ if ('checkout_ref' in r.outputs) {
1331
+ throw new Error('promote-stable must not emit an input-derived checkout ref');
1332
+ }
1333
+}
1334
+
1335
+// A tag/release mismatch must fail before any build can run from the selected commit.
1336
+{
1337
+ const r = runResolver({
1338
+ env: {
1339
+ EVENT_NAME: 'workflow_dispatch',
1340
+ ACTION_INPUT: 'promote-stable',
1341
+ REF_TYPE: 'tag',
1342
+ REF_NAME: '@composio/cli@0.3.0-beta.5',
1343
+ GITHUB_TOKEN: 'fake-token',
1344
+ REPOSITORY: 'ComposioHQ/composio',
1345
+ RUN_NUMBER: '1',
1346
+ COMMIT_SHA: 'selected123',
1347
+ },
1348
+ curlFixture: { prerelease: true, target_commitish: 'release456' },
1349
+ });
1350
+ if (r.status === 0 || !r.stderr.includes('but its release targets')) {
1351
+ throw new Error('promote-stable must reject a beta tag/release commit mismatch');
1352
}
1353
}
1354