From d7a89c2224fdc326a4141a2b4dadd2e4d783d617 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Tue, 10 Dec 2024 18:01:38 +0100 Subject: [PATCH 1/3] fix: PR base branch condition --- template/.github/workflows/build.yml.j2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 43c30ecb..89b520bd 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -346,11 +346,11 @@ jobs: crate: cargo-edit bin: cargo-set-version - name: Update version if PR against main branch - if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }} + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == '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' }} + if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') }} env: PR_NUMBER: ${{ github.event.pull_request.number }} run: | @@ -421,11 +421,11 @@ jobs: crate: cargo-edit bin: cargo-set-version - name: Update version if PR against main branch - if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }} + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == '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' }} + if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') }} env: PR_NUMBER: ${{ github.event.pull_request.number }} run: | From ee48a9acb5312c88e68f956c551c9f6961792bdb Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy <1712947+adwk67@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:06:35 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --- template/.github/workflows/build.yml.j2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 89b520bd..5c7ab3f4 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -347,7 +347,9 @@ jobs: bin: cargo-set-version - name: Update version if PR against main branch if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }} - run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: cargo set-version --offline --workspace 0.0.0-pr${PR_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' && startsWith(github.event.pull_request.base.ref, 'release-') }} @@ -422,7 +424,9 @@ jobs: bin: cargo-set-version - name: Update version if PR against main branch if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }} - run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: cargo set-version --offline --workspace 0.0.0-pr${PR_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' && startsWith(github.event.pull_request.base.ref, 'release-') }} From e396e98ed1bdf3d2650da1422c6262785f6399ca Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Tue, 10 Dec 2024 19:12:03 +0100 Subject: [PATCH 3/3] add variable --- template/.github/workflows/build.yml.j2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 5c7ab3f4..e2f07ce6 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -349,7 +349,9 @@ jobs: if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }} env: PR_NUMBER: ${{ github.event.pull_request.number }} - run: cargo set-version --offline --workspace 0.0.0-pr${PR_NUMBER} + run: | + PR_VERSION="0.0.0-pr${PR_NUMBER}" + cargo set-version --offline --workspace "$PR_VERSION" - 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' && startsWith(github.event.pull_request.base.ref, 'release-') }} @@ -426,7 +428,9 @@ jobs: if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }} env: PR_NUMBER: ${{ github.event.pull_request.number }} - run: cargo set-version --offline --workspace 0.0.0-pr${PR_NUMBER} + run: | + PR_VERSION="0.0.0-pr${PR_NUMBER}" + cargo set-version --offline --workspace "$PR_VERSION" - 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' && startsWith(github.event.pull_request.base.ref, 'release-') }}