Skip to content

Commit 8e7969c

Browse files
adwk67NickLarsenNZ
andauthored
fix: PR base branch condition (#473)
* fix: PR base branch condition * Apply suggestions from code review Co-authored-by: Nick <[email protected]> * add variable --------- Co-authored-by: Nick <[email protected]>
1 parent fe9f74a commit 8e7969c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

template/.github/workflows/build.yml.j2

+14-6
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,15 @@ jobs:
346346
crate: cargo-edit
347347
bin: cargo-set-version
348348
- name: Update version if PR against main branch
349-
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
350-
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
349+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }}
350+
env:
351+
PR_NUMBER: ${{ github.event.pull_request.number }}
352+
run: |
353+
PR_VERSION="0.0.0-pr${PR_NUMBER}"
354+
cargo set-version --offline --workspace "$PR_VERSION"
351355
- name: Update version if PR against non-main branch
352356
# For PRs to be merged against a release branch, use the version that has already been set in the calling script.
353-
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
357+
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') }}
354358
env:
355359
PR_NUMBER: ${{ github.event.pull_request.number }}
356360
run: |
@@ -421,11 +425,15 @@ jobs:
421425
crate: cargo-edit
422426
bin: cargo-set-version
423427
- name: Update version if PR against main branch
424-
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
425-
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
428+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }}
429+
env:
430+
PR_NUMBER: ${{ github.event.pull_request.number }}
431+
run: |
432+
PR_VERSION="0.0.0-pr${PR_NUMBER}"
433+
cargo set-version --offline --workspace "$PR_VERSION"
426434
- name: Update version if PR against non-main branch
427435
# For PRs to be merged against a release branch, use the version that has already been set in the calling script.
428-
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
436+
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') }}
429437
env:
430438
PR_NUMBER: ${{ github.event.pull_request.number }}
431439
run: |

0 commit comments

Comments
 (0)