Skip to content

Commit 26d0e98

Browse files
committed
revert previous change and set version manually for non-main PR case
1 parent 0887500 commit 26d0e98

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,29 @@ jobs:
345345
with:
346346
crate: cargo-edit
347347
bin: cargo-set-version
348+
- name: Update version if PR against main branch
349+
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
350+
run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }}
351+
- name: Update version if PR against non-main branch
352+
# 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.
355+
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
356+
env:
357+
PR_NUMBER: ${{ github.event.pull_request.number }}
358+
run: |
359+
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
360+
PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
361+
sed -i "s/version = \"${MANIFEST_VERSION}\"/version = \"${PR_VERSION}\"/" Cargo.toml
362+
348363
# Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the
349364
# default value in the makefile if called from this action, but not otherwise (i.e. when called locally).
350365
# This is needed for the HELM_REPO variable.
351366
- name: Install cosign
352367
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0
353368
- name: Install syft
354369
uses: anchore/sbom-action/download-syft@61119d458adab75f756bc0b9e4bde25725f86a7a # v0.17.2
355-
- name: Build prerequisites
370+
- name: Build Docker image and Helm chart
356371
run: |
357372
# Installing helm and yq on ubicloud-standard-8-arm only
358373
if [ "$(arch)" = "aarch64" ]; then
@@ -362,29 +377,8 @@ jobs:
362377
sudo apt-get -y install helm
363378
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
364379
fi
365-
- name: Build Docker image and Helm chart - main-PR
366-
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/main' }}
367-
env:
368-
PR_NUMBER: ${{ github.event.pull_request.number }}
369-
run: |
370-
PR_VERSION="0.0.0-pr${PR_NUMBER}"
371-
372-
make -e build PR_VERSION="$PR_VERSION"
373-
- name: Build Docker image and Helm chart - non-main-PR
374-
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
375-
env:
376-
PR_NUMBER: ${{ github.event.pull_request.number }}
377-
run: |
378-
MANIFEST_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
379-
PR_VERSION="${MANIFEST_VERSION}-pr${PR_NUMBER}"
380-
381-
make -e build PR_VERSION="$PR_VERSION"
382-
- name: Build Docker image and Helm chart - non-PR
383-
if: ${{ github.event_name != 'pull_request' }}
384-
run: |
385-
PR_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
386380
387-
make -e build PR_VERSION="$PR_VERSION"
381+
make -e build
388382
- name: Publish Docker image and Helm chart
389383
if: ${{ !github.event.pull_request.head.repo.fork }}
390384
run: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ helm-publish:
142142
cosign sign -y "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_CHARTS}/${HELM_CHART_NAME}@$$REPO_DIGEST_OF_ARTIFACT"
143143

144144
helm-package:
145-
mkdir -p target/helm && helm package --version ${PR_VERSION} --destination target/helm deploy/helm/${OPERATOR_NAME}
145+
mkdir -p target/helm && helm package --destination target/helm deploy/helm/${OPERATOR_NAME}
146146

147147
## Chart related targets
148148
compile-chart: version crds config

0 commit comments

Comments
 (0)