Skip to content

Commit 0c8c77b

Browse files
committed
fix build action: replace cargo set-version with sed for release PRs
1 parent ba80d5a commit 0c8c77b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,15 @@ jobs:
350350
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
351351
- name: Update version if PR against non-main branch
352352
# For PRs to be merged against a release branch, use the version that has already been set in the calling script.
353+
# We can't rely on cargo set-version here as we will break semver rules when changing the version to make it
354+
# specific to this PR e.g. 1.2.0 --> 1.2.0-pr678, so set it manually.
353355
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
354356
env:
355357
PR_NUMBER: ${{ github.event.pull_request.number }}
356358
run: |
357359
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
358360
PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
359-
cargo set-version --offline --workspace "$PR_VERSION"
361+
sed -i "s/version = \"${MANIFEST_VERSION}\"/version = \"${PR_VERSION}\"/" Cargo.toml
360362
361363
# Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the
362364
# default value in the makefile if called from this action, but not otherwise (i.e. when called locally).
@@ -425,13 +427,15 @@ jobs:
425427
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
426428
- name: Update version if PR against non-main branch
427429
# For PRs to be merged against a release branch, use the version that has already been set in the calling script.
430+
# We can't rely on cargo set-version here as we will break semver rules when changing the version to make it
431+
# specific to this PR e.g. 1.2.0 --> 1.2.0-pr678, so set it manually.
428432
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
429433
env:
430434
PR_NUMBER: ${{ github.event.pull_request.number }}
431435
run: |
432436
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
433437
PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
434-
cargo set-version --offline --workspace "$PR_VERSION"
438+
sed -i "s/version = \"${MANIFEST_VERSION}\"/version = \"${PR_VERSION}\"/" Cargo.toml
435439
- name: Build manifest list
436440
run: |
437441
# Creating manifest list

0 commit comments

Comments
 (0)