@@ -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