Skip to content

Commit 0c1f783

Browse files
committed
ci: guard crates.io publish when the token is absent
Skip cargo publish (with a warning) if CARGO_REGISTRY_TOKEN is unset.
1 parent 8285593 commit 0c1f783

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/publish-crate.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
publish:
1414
name: Publish to crates.io
1515
runs-on: ubuntu-latest
16+
env:
17+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
1618
steps:
1719
- uses: actions/checkout@v4
1820
- uses: dtolnay/rust-toolchain@stable
@@ -21,7 +23,9 @@ jobs:
2123
cargo fmt --check
2224
cargo clippy --all-targets --all-features -- -D warnings
2325
cargo test --all-features
24-
- name: Publish
25-
env:
26-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
26+
- name: Publish to crates.io
27+
if: env.CARGO_REGISTRY_TOKEN != ''
2728
run: cargo publish
29+
- name: Skip publish (no token configured)
30+
if: env.CARGO_REGISTRY_TOKEN == ''
31+
run: echo "::warning::CARGO_REGISTRY_TOKEN secret is not set; skipping crates.io publish. Add it under repo Settings > Secrets and re-run."

0 commit comments

Comments
 (0)