Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: more reliable dev version tagging (#1424)
## Which problem is this PR solving? - Image builds in Circle were still using the job ID as the version. ## Short description of the changes - Reliably set the version regardless of where the image build is being run. - Moves the image tagging logic to below the version-determination logic. Now the dev-build tagging can reuse the determined dev version instead of using the CircleCI build ID. - Sets some defaults for environment variables to appease the `nounset` shell rule when this script is run outside of CI. ## Example Outputs ### Dev build in Dev ``` ❯ ./build-docker.sh ++ git describe --tags '--match=v[0-9]*' --always + VERSION=2.8.2-58-g264d4af … + GOFLAGS=-ldflags=-X=main.BuildID=2.8.2-58-g264d4af … + ./ko publish --tags 2.8.2-55-gcc8c2a2 … … 2024/11/12 13:58:26 Adding tag 2.8.2-55-gcc8c2a2 … ``` ### [Dev build off branch in CI](https://app.circleci.com/pipelines/github/honeycombio/refinery/4519/workflows/956f775f-f48d-4938-8e87-ca32feb551e6/jobs/13888?invite=true#step-106-1804_56) ``` #!/bin/bash -eo pipefail ./build-docker.sh … + GOFLAGS=-ldflags=-X=main.BuildID=2.8.2-58-g264d4af-ci13888 … 2024/11/12 18:34:40 Adding tag 2.8.2-58-g264d4af-ci13888 2024/11/12 18:34:40 Adding tag branch-robb.use-new-dev-version-as-tag-for-dev-builds … ``` ### Dev build off branch in simulated CI ``` ❯ CIRCLE_BUILD_NUM=8675309 CIRCLE_BRANCH=$(git rev-parse --abbrev-ref HEAD) ./build-docker.sh ++ git describe --tags '--match=v[0-9]*' --always + VERSION=v2.8.2-55-gcc8c2a2 … + GOFLAGS=-ldflags=-X=main.BuildID=2.8.2-58-g264d4af-ci8675309 … + ./ko publish --tags 2.8.2-55-gcc8c2a2-ci8675309,branch-robb.use-new-dev-version-as-tag-for-dev-builds … 2024/11/12 14:02:32 Adding tag 2.8.2-55-gcc8c2a2-ci8675309 2024/11/12 14:02:32 Adding tag branch-robb.use-new-dev-version-as-tag-for-dev-builds … ``` ### Dev build off main in simulated CI ``` ❯ CIRCLE_BUILD_NUM=8675309 CIRCLE_BRANCH=main ./build-docker.sh … + GOFLAGS=-ldflags=-X=main.BuildID=2.8.2-58-g264d4af-ci8675309 … 2024/11/12 14:13:54 Adding tag 2.8.2-55-gcc8c2a2-ci8675309 2024/11/12 14:13:54 Adding tag branch-main 2024/11/12 14:13:54 Adding tag latest … ``` ### Tagged release build off main in simulated CI ``` ❯ CIRCLE_BUILD_NUM=8675309 CIRCLE_BRANCH=main CIRCLE_TAG=v999.99.9 ./build-docker.sh … + GOFLAGS=-ldflags=-X=main.BuildID=999.99.9 … 2024/11/12 14:16:32 Adding tag 999 2024/11/12 14:16:32 Adding tag 999.99 2024/11/12 14:16:32 Adding tag 999.99.9 2024/11/12 14:16:32 Adding tag latest … ``` --------- Co-authored-by: Mike Goldsmith <[email protected]>
- Loading branch information