Skip to content

Commit 2b806e1

Browse files
adwk67NickLarsenNZ
andauthored
ci: set PR-suffix on PRs against non-main/release branches (#471)
* set PR suffix on PRs against release branches * added comment * Update template/.github/workflows/build.yml.j2 Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update template/.github/workflows/build.yml.j2 Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent 13ec44c commit 2b806e1

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

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

+20-4
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,18 @@ jobs:
344344
with:
345345
crate: cargo-edit
346346
bin: cargo-set-version
347-
- name: Update version if PR
348-
# For PRs to be merged against a release branch, the version has already been set, in which case ignore this step.
347+
- name: Update version if PR against main branch
349348
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
350349
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
350+
- name: Update version if PR against non-main branch
351+
# For PRs to be merged against a release branch, use the version that has already been set in the calling script.
352+
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
353+
env:
354+
PR_NUMBER: ${{ github.event.pull_request.number }}
355+
run: |
356+
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
357+
PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
358+
cargo set-version --offline --workspace "$PR_VERSION"
351359

352360
# Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the
353361
# default value in the makefile if called from this action, but not otherwise (i.e. when called locally).
@@ -411,10 +419,18 @@ jobs:
411419
with:
412420
crate: cargo-edit
413421
bin: cargo-set-version
414-
- name: Update version if PR
415-
# For PRs to be merged against a release branch, the version has already been set, in which case ignore this step.
422+
- name: Update version if PR against main branch
416423
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
417424
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
425+
- name: Update version if PR against non-main branch
426+
# For PRs to be merged against a release branch, use the version that has already been set in the calling script.
427+
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
428+
env:
429+
PR_NUMBER: ${{ github.event.pull_request.number }}
430+
run: |
431+
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
432+
PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
433+
cargo set-version --offline --workspace "$PR_VERSION"
418434
- name: Build manifest list
419435
run: |
420436
# Creating manifest list

0 commit comments

Comments
 (0)