Skip to content

Commit 5aceaad

Browse files
authored
CI - Fix npm dry run, and release dry runs actually testing the specified branch (#5636)
# Description of Changes Closes #5635. tl;dr it seems like newer versions of `npm publish` actually check whether the package version is already published. This causes release dry runs to fail when they didn't before. Fixed by slightly weakening the publish dry run. This also fixes a bug in the release workflow, so that release dry runs check out the specific ref that the workflow is running from, rather than the release tag. Unfortunately these two independent fixes need to be bundled into a single PR, because neither can pass CI without the other right now. # API and ABI breaking changes none # Expected complexity level and risk 2 # Testing - [x] Release dry run passes on this PR --------- Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent bbfea56 commit 5aceaad

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ jobs:
103103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104104

105105
steps:
106-
- name: Checkout specific tag
106+
- name: Checkout release source
107107
uses: actions/checkout@v4
108108
with:
109-
ref: ${{ github.event.inputs.release_tag }}
109+
ref: ${{ inputs.dry_run && github.sha || github.event.inputs.release_tag }}
110110
submodules: recursive
111111

112112
- name: Set up Rust
@@ -145,10 +145,10 @@ jobs:
145145
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
146146

147147
steps:
148-
- name: Checkout specific tag
148+
- name: Checkout release source
149149
uses: actions/checkout@v4
150150
with:
151-
ref: ${{ github.event.inputs.release_tag }}
151+
ref: ${{ inputs.dry_run && github.sha || github.event.inputs.release_tag }}
152152
submodules: recursive
153153

154154
- name: Set up Rust
@@ -223,10 +223,10 @@ jobs:
223223
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224224

225225
steps:
226-
- name: Checkout specific tag
226+
- name: Checkout release source
227227
uses: actions/checkout@v4
228228
with:
229-
ref: ${{ github.event.inputs.release_tag }}
229+
ref: ${{ inputs.dry_run && github.sha || github.event.inputs.release_tag }}
230230
submodules: recursive
231231

232232
- name: Set up Rust
@@ -284,10 +284,10 @@ jobs:
284284
packages: write
285285

286286
steps:
287-
- name: Checkout specific tag
287+
- name: Checkout release source
288288
uses: actions/checkout@v4
289289
with:
290-
ref: ${{ github.event.inputs.release_tag }}
290+
ref: ${{ inputs.dry_run && github.sha || github.event.inputs.release_tag }}
291291
submodules: recursive
292292

293293
- name: Download cargo-release
@@ -332,10 +332,10 @@ jobs:
332332
if: ${{ inputs.release_docker }}
333333

334334
steps:
335-
- name: Checkout specific tag
335+
- name: Checkout release source
336336
uses: actions/checkout@v4
337337
with:
338-
ref: ${{ github.event.inputs.release_tag }}
338+
ref: ${{ inputs.dry_run && github.sha || github.event.inputs.release_tag }}
339339
submodules: recursive
340340

341341
- name: Download cargo-release

tools/release/src/targets/npm.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ impl NpmRelease {
5959
// on the main/master branch (we're in a detached HEAD state at this point).
6060
// ERR_PNPM_GIT_UNKNOWN_BRANCH The Git HEAD may not attached to any branch, but your "publish-branch" is set to "master|main".
6161
if self.dry_run {
62-
cmd.args(["publish", "--dry-run", "--no-git-checks"]);
62+
// --force is required to override the "package already exists" complaint
63+
cmd.args(["publish", "--dry-run", "--force", "--no-git-checks"]);
6364
} else {
6465
cmd.args(["publish", "--no-git-checks"]);
6566
}

0 commit comments

Comments
 (0)