Skip to content

Commit

Permalink
ci: on release check git version matches release version in code
Browse files Browse the repository at this point in the history
Signed-off-by: Eguzki Astiz Lezaun <[email protected]>
  • Loading branch information
eguzki committed Oct 24, 2024
1 parent 7db4ff5 commit 797e3f9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/build-images-for-tag-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Read release string version
id: release
run: |
version=`make read-release-version`
echo version=$version >> $GITHUB_OUTPUT
- name: Print tags
run: echo "Git reference name = ${{ github.ref_name }}, release version = ${{ steps.release.outputs.version }}"
- name: Verify git reference name matches the release version
if: ${{ github.ref_name != steps.release.outputs.version }}
run: exit 1

- name: Install qemu dependency
run: |
sudo apt-get update
Expand Down
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,17 @@ YQ = $(LOCALBIN)/yq
GINKGO ?= $(LOCALBIN)/ginkgo
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
HELM ?= $(LOCALBIN)/helm
ifeq ($(shell uname),Darwin)
SED=$(shell which gsed)
else
SED=$(shell which sed)
endif
.PHONY: sed
sed: ## Checks if GNU sed is installed
ifeq ($(SED),)
@echo "Cannot find GNU sed installed."
exit 1
endif

## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.1
Expand Down Expand Up @@ -532,7 +543,15 @@ prepare-release: ## Generates a makefile that will override environment variable
VERSION=$(VERSION)\nREPLACES_VERSION=$(REPLACES_VERSION)" > $(RELEASE_FILE)
$(MAKE) bundle
$(MAKE) helm-build VERSION=$(VERSION)
sed -i -e 's/Version = ".*"/Version = "$(VERSION)"/' $(PROJECT_PATH)/internal/version/version.go
$(MAKE) update-release-version VERSION=$(VERSION)

.PHONY: read-version
read-release-version: ## Reads release version
@$(SED) -n 's/^.*Version = "\([^"]*\)".*/\1/p' $(PROJECT_PATH)/internal/version/version.go

.PHONY: update-release-version
update-release-version: ## Updates release version to $(VERSION)
$(SED) -i -e 's/Version = ".*"/Version = "$(VERSION)"/' $(PROJECT_PATH)/internal/version/version.go

# Include last to avoid changing MAKEFILE_LIST used above
include ./make/*.mk

0 comments on commit 797e3f9

Please sign in to comment.