Skip to content

Commit 1ae2af9

Browse files
committed
chore(ci): use --locked for crate publication commands
1 parent 0318b38 commit 1ae2af9

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/make_release_common.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ jobs:
6060
- name: Prepare package
6161
env:
6262
PACKAGE: ${{ inputs.package-name }}
63+
# --locked: fail rather than silently re-resolve if Cargo.lock is out of date, so a
64+
# release can never pick up a dependency version that was not already reviewed.
6365
run: |
64-
cargo package -p "${PACKAGE}"
66+
cargo package --locked -p "${PACKAGE}"
6567
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6668
with:
6769
name: crate-${{ inputs.package-name }}
@@ -115,11 +117,13 @@ jobs:
115117
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
116118
PACKAGE: ${{ inputs.package-name }}
117119
DRY_RUN: ${{ inputs.dry-run && '--dry-run' || '' }}
120+
# DRY_RUN expansion cannot be double quoted when variable contains empty string otherwise cargo publish
121+
# would fail. This is safe since DRY_RUN is handled in the env section above.
122+
# --locked: see the packaging step. Matters most here, where a dependency build script
123+
# would run with CARGO_REGISTRY_TOKEN in the environment.
118124
run: |
119-
# DRY_RUN expansion cannot be double quoted when variable contains empty string otherwise cargo publish
120-
# would fail. This is safe since DRY_RUN is handled in the env section above.
121125
# shellcheck disable=SC2086
122-
cargo publish -p "${PACKAGE}" ${DRY_RUN}
126+
cargo publish --locked -p "${PACKAGE}" ${DRY_RUN}
123127
124128
- name: Generate hash
125129
id: published_hash

.github/workflows/make_release_common_cuda.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ jobs:
120120
- name: Prepare package
121121
env:
122122
PACKAGE: ${{ inputs.package-name }}
123+
# --locked: fail rather than silently re-resolve if Cargo.lock is out of date, so a
124+
# release can never pick up a dependency version that was not already reviewed.
123125
run: |
124-
cargo package -p "${PACKAGE}"
126+
cargo package --locked -p "${PACKAGE}"
125127
126128
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
127129
with:
@@ -210,11 +212,13 @@ jobs:
210212
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
211213
PACKAGE: ${{ inputs.package-name }}
212214
DRY_RUN: ${{ inputs.dry-run && '--dry-run' || '' }}
215+
# DRY_RUN expansion cannot be double quoted when variable contains empty string otherwise cargo publish
216+
# would fail. This is safe since DRY_RUN is handled in the env section above.
217+
# --locked: see the packaging step. Matters most here, where a dependency build script
218+
# would run with CARGO_REGISTRY_TOKEN in the environment.
213219
run: |
214-
# DRY_RUN expansion cannot be double quoted when variable contains empty string otherwise cargo publish
215-
# would fail. This is safe since DRY_RUN is handled in the env section above.
216220
# shellcheck disable=SC2086
217-
cargo publish -p "${PACKAGE}" ${DRY_RUN}
221+
cargo publish --locked -p "${PACKAGE}" ${DRY_RUN}
218222
219223
- name: Generate hash
220224
id: published_hash

0 commit comments

Comments
 (0)