Skip to content

Commit 4f21202

Browse files
committed
fix(ci): scope the CLI telemetry token to the build and publish steps
1 parent d0a9497 commit 4f21202

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎.github/workflows/publish-sim-cli.yml‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ concurrency:
2020

2121
jobs:
2222
publish-npm:
23-
# Job-level, not on the build step: `bun publish` runs `prepublishOnly`,
24-
# which rebuilds `dist` a second time, and that second build is the one
25-
# that ships. A build without the token reports nothing. See
26-
# docs/cli/usage-data.
27-
env:
28-
SIM_CLI_TELEMETRY_KEY: ${{ vars.SIM_CLI_TELEMETRY_KEY }}
29-
SIM_CLI_TELEMETRY_HOST: ${{ vars.SIM_CLI_TELEMETRY_HOST }}
3023
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
3124
timeout-minutes: 15
3225
steps:
@@ -73,8 +66,15 @@ jobs:
7366
working-directory: packages/sim-cli
7467
run: bun run type-check
7568

69+
# The usage-reporting destination is baked into the bundle at build time
70+
# (docs/cli/usage-data), so only the two steps that build it get the
71+
# token. Every other step, the tests above in particular, runs without
72+
# it: a test that runs a real command must never report to production.
7673
- name: Build package
7774
working-directory: packages/sim-cli
75+
env:
76+
SIM_CLI_TELEMETRY_KEY: ${{ vars.SIM_CLI_TELEMETRY_KEY }}
77+
SIM_CLI_TELEMETRY_HOST: ${{ vars.SIM_CLI_TELEMETRY_HOST }}
7878
run: bun run build
7979

8080
- name: Resolve release channel
@@ -140,11 +140,15 @@ jobs:
140140
exit 1
141141
fi
142142
143+
# `bun publish` runs `prepublishOnly`, which rebuilds `dist`, and that
144+
# rebuild is what ships, so it needs the token as well.
143145
- name: Publish to npm
144146
working-directory: packages/sim-cli
145147
env:
146148
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
147149
NPM_TAG: ${{ steps.release.outputs.tag }}
150+
SIM_CLI_TELEMETRY_KEY: ${{ vars.SIM_CLI_TELEMETRY_KEY }}
151+
SIM_CLI_TELEMETRY_HOST: ${{ vars.SIM_CLI_TELEMETRY_HOST }}
148152
run: bun publish --access public --tag "$NPM_TAG" --no-save
149153

150154
- name: Summarize release

0 commit comments

Comments
 (0)