Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch the latest tag from the remote #885

Merged
merged 1 commit into from May 2, 2022

Conversation

jkremser
Copy link
Member

@jkremser jkremser commented May 2, 2022

WHY:
Because if users don't regularly call the git fetch --tags on the repo, the tags are not updated in their git repos after the release and it may happen that old version will be deployed. However, if the user called git pull and has the latests manifests, those are not guaranteed to work with some old release.

It may sound quite artificial, but it happens and I also caught myself that make deploy-full-local-setup deploys some older version if I didn't pull the latest tags.

HOW:
Using := in the makefile so that the bash expression is evaluated only once, inside of the ifndef VERSION macro, so that we can have both: overridable value passed as env var to make and lazy evaluation

git fetch is not a fast operation, for me it takes ~1.3 sec. I did some measurements with this dummy target:

foo:
	echo $(VERSION)
	echo $(VERSION)
	echo $(VERSION)
	echo $(VERSION)
	echo $(VERSION)
time make foo
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
make foo  0.05s user 0.08s system 8% cpu 1.535 total
time VERSION=42 make foo
echo 42
42
echo 42
42
echo 42
42
echo 42
42
echo 42
42
VERSION=42 make foo  0.01s user 0.01s system 27% cpu 0.086 total

If the ?= and no ifndef macro was used, the results are:

time make foo
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
echo v0.9.0
v0.9.0
make foo  0.25s user 0.34s system 8% cpu 7.071 total

note: this change doesn't break the reproducibility of old releases in a sense that even if I checkout some old commit and run the deploy-full-local-setup, the correct git tag will be used (the latest released up to that checked commit, not the very latest one)

Signed-off-by: Jirka Kremser jiri.kremser@gmail.com

Makefile Outdated Show resolved Hide resolved
Signed-off-by: Jirka Kremser <jiri.kremser@gmail.com>
@jkremser jkremser merged commit f3131c4 into k8gb-io:master May 2, 2022
@jkremser jkremser deleted the fetch-latest-version branch May 2, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants