Skip to content

Commit d353a4c

Browse files
committed
set PR suffix on PRs against release branches
1 parent 13ec44c commit d353a4c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,15 @@ 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+
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
352+
run: |
353+
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
354+
PR_VERSION="${MANIFEST_VERSION}-pr${{ github.event.pull_request.number }}"
355+
cargo set-version --offline --workspace "$PR_VERSION"
351356

352357
# Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the
353358
# default value in the makefile if called from this action, but not otherwise (i.e. when called locally).
@@ -411,10 +416,15 @@ jobs:
411416
with:
412417
crate: cargo-edit
413418
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.
419+
- name: Update version if PR against main branch
416420
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
417421
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
422+
- name: Update version if PR against non-main branch
423+
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
424+
run: |
425+
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
426+
PR_VERSION="${MANIFEST_VERSION}-pr${{ github.event.pull_request.number }}"
427+
cargo set-version --offline --workspace "$PR_VERSION"
418428
- name: Build manifest list
419429
run: |
420430
# Creating manifest list

0 commit comments

Comments
 (0)