From d353a4c80cc5c97d3443f5fca25fd928fddd5506 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Thu, 5 Dec 2024 17:41:43 +0100 Subject: [PATCH 1/4] set PR suffix on PRs against release branches --- template/.github/workflows/build.yml.j2 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 5e4ba77d..06badcc5 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -344,10 +344,15 @@ jobs: with: crate: cargo-edit bin: cargo-set-version - - name: Update version if PR - # For PRs to be merged against a release branch, the version has already been set, in which case ignore this step. + - name: Update version if PR against main branch if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }} run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} + - name: Update version if PR against non-main branch + if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }} + run: | + MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version') + PR_VERSION="${MANIFEST_VERSION}-pr${{ github.event.pull_request.number }}" + cargo set-version --offline --workspace "$PR_VERSION" # Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the # default value in the makefile if called from this action, but not otherwise (i.e. when called locally). @@ -411,10 +416,15 @@ jobs: with: crate: cargo-edit bin: cargo-set-version - - name: Update version if PR - # For PRs to be merged against a release branch, the version has already been set, in which case ignore this step. + - name: Update version if PR against main branch if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }} run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} + - name: Update version if PR against non-main branch + if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }} + run: | + MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version') + PR_VERSION="${MANIFEST_VERSION}-pr${{ github.event.pull_request.number }}" + cargo set-version --offline --workspace "$PR_VERSION" - name: Build manifest list run: | # Creating manifest list From 29f44684058c65c54e909139e54fffb4234dc790 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Fri, 6 Dec 2024 09:42:51 +0100 Subject: [PATCH 2/4] added comment --- template/.github/workflows/build.yml.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 06badcc5..63ae8585 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -348,6 +348,7 @@ jobs: if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }} run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} - name: Update version if PR against non-main branch + # For PRs to be merged against a release branch, use the version that has already been set in the calling script. if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }} run: | MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version') @@ -420,6 +421,7 @@ jobs: if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }} run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} - name: Update version if PR against non-main branch + # For PRs to be merged against a release branch, use the version that has already been set in the calling script. if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }} run: | MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version') From e5033730dab90613156bb681df5775aab0f4954c Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy <1712947+adwk67@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:30:14 +0100 Subject: [PATCH 3/4] Update template/.github/workflows/build.yml.j2 Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --- template/.github/workflows/build.yml.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 63ae8585..7f72fa32 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -423,9 +423,11 @@ jobs: - name: Update version if PR against non-main branch # For PRs to be merged against a release branch, use the version that has already been set in the calling script. if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} run: | MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version') - PR_VERSION="${MANIFEST_VERSION}-pr${{ github.event.pull_request.number }}" + PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}" cargo set-version --offline --workspace "$PR_VERSION" - name: Build manifest list run: | From b69483628b11318b78c1865bdd399f99a5e48e42 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy <1712947+adwk67@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:30:20 +0100 Subject: [PATCH 4/4] Update template/.github/workflows/build.yml.j2 Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --- template/.github/workflows/build.yml.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 7f72fa32..926fbce2 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -350,9 +350,11 @@ jobs: - name: Update version if PR against non-main branch # For PRs to be merged against a release branch, use the version that has already been set in the calling script. if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} run: | MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version') - PR_VERSION="${MANIFEST_VERSION}-pr${{ github.event.pull_request.number }}" + PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}" cargo set-version --offline --workspace "$PR_VERSION" # Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the