Skip to content

Commit 11a245d

Browse files
committed
chore(ci): use --locked for crate publication commands
1 parent a088e8f commit 11a245d

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

.github/workflows/make_release_common.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ jobs:
6060
- name: Prepare package
6161
env:
6262
PACKAGE: ${{ inputs.package-name }}
63-
run: |
64-
cargo package -p "${PACKAGE}"
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.
65+
run: cargo package --locked -p "${PACKAGE}"
6566
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6667
with:
6768
name: crate-${{ inputs.package-name }}
@@ -115,11 +116,13 @@ jobs:
115116
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
116117
PACKAGE: ${{ inputs.package-name }}
117118
DRY_RUN: ${{ inputs.dry-run && '--dry-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.
121+
# --locked: see the packaging step. Matters most here, where a dependency build script
122+
# would run with CARGO_REGISTRY_TOKEN in the environment.
118123
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.
121124
# shellcheck disable=SC2086
122-
cargo publish -p "${PACKAGE}" ${DRY_RUN}
125+
cargo publish --locked -p "${PACKAGE}" ${DRY_RUN}
123126
124127
- name: Generate hash
125128
id: published_hash

.github/workflows/make_release_common_cuda.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ jobs:
120120
- name: Prepare package
121121
env:
122122
PACKAGE: ${{ inputs.package-name }}
123-
run: |
124-
cargo package -p "${PACKAGE}"
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.
125+
run: cargo package --locked -p "${PACKAGE}"
125126

126127
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
127128
with:
@@ -210,11 +211,13 @@ jobs:
210211
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
211212
PACKAGE: ${{ inputs.package-name }}
212213
DRY_RUN: ${{ inputs.dry-run && '--dry-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.
216+
# --locked: see the packaging step. Matters most here, where a dependency build script
217+
# would run with CARGO_REGISTRY_TOKEN in the environment.
213218
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.
216219
# shellcheck disable=SC2086
217-
cargo publish -p "${PACKAGE}" ${DRY_RUN}
220+
cargo publish --locked -p "${PACKAGE}" ${DRY_RUN}
218221
219222
- name: Generate hash
220223
id: published_hash

0 commit comments

Comments
 (0)