@@ -354,13 +354,18 @@ jobs:
354354 cargo set-version --offline --workspace "$PR_VERSION"
355355 - name : Update version if PR against non-main branch
356356 # For PRs to be merged against a release branch, use the version that has already been set in the calling script.
357- if : ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') }}
357+ # We can't rely on cargo set-version here as we will break semver rules when changing the version to make it
358+ # specific to this PR e.g. 1.2.0 --> 1.2.0-pr678, so set it manually.
359+ if : ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
358360 env :
359361 PR_NUMBER : ${{ github.event.pull_request.number }}
362+ shell : bash
360363 run : |
364+ set -euo pipefail
365+
361366 MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
362367 PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
363- cargo set- version --offline --workspace "$ PR_VERSION"
368+ sed -i "s/ version = \"${MANIFEST_VERSION}\"/version = \"${ PR_VERSION}\"/" Cargo.toml
364369
365370 # Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the
366371 # default value in the makefile if called from this action, but not otherwise (i.e. when called locally).
@@ -433,13 +438,18 @@ jobs:
433438 cargo set-version --offline --workspace "$PR_VERSION"
434439 - name : Update version if PR against non-main branch
435440 # For PRs to be merged against a release branch, use the version that has already been set in the calling script.
436- if : ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') }}
441+ # We can't rely on cargo set-version here as we will break semver rules when changing the version to make it
442+ # specific to this PR e.g. 1.2.0 --> 1.2.0-pr678, so set it manually.
443+ if : ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
437444 env :
438445 PR_NUMBER : ${{ github.event.pull_request.number }}
446+ shell : bash
439447 run : |
448+ set -euo pipefail
449+
440450 MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
441451 PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
442- cargo set- version --offline --workspace "$ PR_VERSION"
452+ sed -i "s/ version = \"${MANIFEST_VERSION}\"/version = \"${ PR_VERSION}\"/" Cargo.toml
443453 - name : Build manifest list
444454 run : |
445455 # Creating manifest list
0 commit comments