D2: gate the publish jobs behind a protected environment

release.yml triggers on every v* tag push and the four publish jobs
(crates.io, PyPI, npm, wasm) inject long-lived registry tokens straight
from secrets with no environment, no reviewer and no tag restriction.

Bind all four jobs to a `release` GitHub environment. With the
environment's protection rules (required reviewers, tag/branch
restrictions) configured under repo Settings -> Environments, the
registry secrets become reachable only from an approved release run
rather than from any workflow execution.
This commit is contained in:
kingchenc
2026-05-22 12:32:47 +02:00
parent 8ccb885906
commit 0d451ac584
+10
View File
@@ -15,6 +15,13 @@ jobs:
cargo-publish:
name: Publish to crates.io
runs-on: ubuntu-latest
# The publish jobs run with long-lived registry tokens. Binding them to a
# protected GitHub environment lets the org require a reviewer to approve
# each release and restrict which tags/branches may deploy, so the secrets
# are not reachable from an arbitrary workflow run. The `release`
# environment and its protection rules are configured under repo
# Settings -> Environments.
environment: release
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
@@ -122,6 +129,7 @@ jobs:
name: Publish to PyPI
needs: [python-wheels, python-sdist]
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/download-artifact@v4
with:
@@ -185,6 +193,7 @@ jobs:
name: Publish to npm
needs: node-build
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
@@ -309,6 +318,7 @@ jobs:
wasm-publish:
name: Publish wickra-wasm to npm
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4