From 515a7e3efae3855fc788f5225d4b5cb57cb682ae Mon Sep 17 00:00:00 2001 From: Paul Abel <128620221+pdabelf5@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:22:09 +0000 Subject: [PATCH] switch to using static file for version (#4973) --- .github/data/version.txt | 2 ++ .github/workflows/ci.yml | 16 +++++++++++++--- .goreleaser.yml | 2 +- Makefile | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .github/data/version.txt diff --git a/.github/data/version.txt b/.github/data/version.txt new file mode 100644 index 0000000000..c7dab5cdea --- /dev/null +++ b/.github/data/version.txt @@ -0,0 +1,2 @@ +IC_VERSION=3.5.0 +HELM_CHART_VERSION=1.2.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f15a979024..95c0fc8849 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,7 @@ jobs: go_code_md5: ${{ steps.vars.outputs.go_code_md5 }} chart_version: ${{ steps.vars.outputs.chart_version }} binary_cache_hit: ${{ steps.binary-cache.outputs.cache-hit }} + ic_version: ${{ steps.vars.outputs.ic_version }} steps: - name: Checkout Repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -57,7 +58,6 @@ jobs: | sed 's/^.\{1\}//' \ | tr -d '\n') echo "k8s_latest=$kindest_latest" >> $GITHUB_OUTPUT - echo "chart_version=$(yq '.version' > $GITHUB_OUTPUT echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT kindest_versions=$(curl -s "https://hub.docker.com/v2/repositories/kindest/node/tags" \ | grep -o '"name": *"[^"]*' \ @@ -72,7 +72,10 @@ jobs: | sed 's/, $//' \ | jq -R -s -c 'split("\n")[:-1]') echo "latest_kindest_node_versions=$kindest_versions" >> $GITHUB_OUTPUT - echo go_code_md5=$(find . -type f \( -name "*.go" -o -name go.mod -o -name go.sum -o -name "*.tmpl" \) -not -path "./docs*" -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1 }') >> $GITHUB_OUTPUT + echo go_code_md5=$(find . -type f \( -name "*.go" -o -name go.mod -o -name go.sum -o -name "*.tmpl" -o -name .goreleaser.yml -o -name .github/data/version.txt \) -not -path "./docs*" -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1 }') >> $GITHUB_OUTPUT + source .github/data/version.txt + echo "ic_version=${IC_VERSION}" >> $GITHUB_OUTPUT + echo "chart_version=${HELM_CHART_VERSION}" >> $GITHUB_OUTPUT cat $GITHUB_OUTPUT - name: Fetch Cached Binary Artifacts @@ -201,6 +204,7 @@ jobs: AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} AZURE_BUCKET_NAME: ${{ secrets.AZURE_BUCKET_NAME }} + GORELEASER_CURRENT_TAG: ${{ needs.checks.outputs.ic_version }} if: ${{ needs.checks.outputs.binary_cache_hit != 'true' }} - name: Store Artifacts in Cache @@ -513,7 +517,13 @@ jobs: - name: Package id: package run: | - output=$(helm package ${{ github.ref_type != 'tag' && '--app-version edge --version 0.0.0-edge' || '' }} kic/charts/nginx-ingress) + helm_versions="" + if [ ${{ github.ref_type }} != "tag" ]; then + helm_versions="--app-version edge --version 0.0.0-edge" + else + helm_versions="--app-version ${{ steps.checks.outputs.ic_version }} --version ${{ steps.checks.outputs.chart_version }}" + fi + output=$(helm package ${helm_versions} kic/charts/nginx-ingress) echo "path=$(basename -- $(echo $output | cut -d: -f2))" >> $GITHUB_OUTPUT - name: Push to OCI registries diff --git a/.goreleaser.yml b/.goreleaser.yml index 8a058e2e40..994e3ce8ae 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -137,4 +137,4 @@ milestones: - close: true snapshot: - name_template: 'edge' + name_template: '{{.Version}}' diff --git a/Makefile b/Makefile index 9589e65acc..0da24455f8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # variables that should not be overridden by the user +VER = $(shell grep IC_VERSION .github/data/version.txt | cut -d '=' -f 2) GIT_TAG = $(shell git tag --sort=-version:refname | head -n1 || echo untagged) -VERSION = $(GIT_TAG)-SNAPSHOT +VERSION = $(VER)-SNAPSHOT PLUS_ARGS = --secret id=nginx-repo.crt,src=nginx-repo.crt --secret id=nginx-repo.key,src=nginx-repo.key # Additional flags added here can be accessed in main.go.