diff --git a/.github/workflows/precompile.yml b/.github/workflows/precompile.yml index d5c5920..3ffac5e 100644 --- a/.github/workflows/precompile.yml +++ b/.github/workflows/precompile.yml @@ -4,12 +4,21 @@ on: tags: ['v*'] # Every `uses:` below is pinned to a full commit SHA rather than a moving tag. -# This is the workflow that holds HEX_API_KEY, so a retagged action would be a -# supply-chain takeover of the published package. Pinned releases: +# This workflow publishes the package, so a retagged action would be a +# supply-chain takeover of it. Pinned releases: # actions/checkout v6.1.0 -> d23441a48e516b6c34aea4fa41551a30e30af803 # erlef/setup-beam v1.24.1 -> 54075bcc5e249e4758d363f27d099f55d843f124 # Re-resolve with `git ls-remote https://github.com// 'refs/tags/v*'` # and take the dereferenced (`^{}`) line when the tag is annotated. +# +# HEX_API_KEY lives in the `hex` environment, not in repository secrets, so +# only the `publish` job can read it. The environment admits `v*` tags only +# and waits for a required reviewer, so nothing reaches Hex without an approval +# after the artifacts and checksums are in place. + +# Jobs that need more ask for it themselves. +permissions: + contents: read env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true @@ -129,6 +138,9 @@ jobs: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: submodules: recursive + # This job builds llama.cpp with contents: write; keep the token out + # of .git. The upload step gets its own GH_TOKEN. + persist-credentials: false # Before setup-beam, which installs into the tool cache this would remove. - name: Free disk space for the CUDA toolkit if: matrix.toolkit != '' @@ -382,6 +394,8 @@ jobs: name: Publish to Hex runs-on: ubuntu-22.04 needs: [checksum] + # The only job that can read HEX_API_KEY (see the header). + environment: hex permissions: contents: read steps: @@ -392,6 +406,9 @@ jobs: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: ref: ${{ github.ref }} + # No git token beside the Hex key. The fetch below is anonymous; the + # repository is public. + persist-credentials: false - name: Take the generated checksum.exs from master run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ac3247..7828045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,11 @@ Qwen3.8-27B NVFP4 is unchanged (`bench/spark_spec.exs`: plain 14.21, MTP branches, `draft-ctx-other-devices` is upstream; `rpc-add-server-no-abort` and `rpc-client-spin-wait` are not and still apply; `cuda-mmq-src1-reuse` conflicts with #31296 and #31047. +- Release workflow: `HEX_API_KEY` moves from repository secrets to a `hex` + GitHub environment that only the `publish` job declares. The environment + accepts `v*` tags only and needs a reviewer's approval before anything + reaches Hex. The `precompile` and `publish` checkouts no longer leave a git + token in `.git`, and the workflow defaults to `contents: read`. ### Fixed diff --git a/docs/release-guide.md b/docs/release-guide.md index bd4f347..686edc9 100644 --- a/docs/release-guide.md +++ b/docs/release-guide.md @@ -519,12 +519,16 @@ publish. The jobs run in this order: release out of draft, runs `mix elixir_make.checksum --all`, verifies the resulting `checksum.exs` has an entry for each of them, and commits it to `master`. -4. **`publish`** checks out the **tag** (not `master`), takes only `checksum.exs` - from `master`, compiles once to verify the published artifact against those - checksums, and runs `mix hex.publish --yes`. - -So there is nothing to do by hand after the tag push. Watch the run; if a leg -fails, the release stays a draft and nothing reaches Hex. +4. **`publish`** runs in the `hex` GitHub environment, the only place + `HEX_API_KEY` lives. The environment accepts `v*` tags only and has a + required reviewer, so the job **waits for approval** (Actions → the run → + *Review deployments*). Approve once the release and `checksum.exs` look + right. It checks out the **tag** (not `master`), takes only `checksum.exs` + from `master`, verifies every published artifact against those checksums, + compiles once, and runs `mix hex.publish --yes`. + +The only manual step after the tag push is that approval. Watch the run; if a +leg fails, the release stays a draft and nothing reaches Hex. If you ever need to publish manually — a workflow outage, say — reproduce what `publish` does rather than publishing from `master`: