fix dirty commit version (#21062)

* fix release script detecting dirty commit

* add go-licenses to gitignore

* add more help text
pull/21066/head
Medya Ghazizadeh 2025-07-14 10:49:49 -07:00 committed by GitHub
parent 0988cc3a72
commit 7d8d9741db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

1
.gitignore vendored
View File

@ -64,3 +64,4 @@ test/integration/testdata/minikube-linux-amd64-latest-stable
hack/legacy_fill_db/gopogh_filldb_log.txt
hack/legacy_fill_db/out/output_summary.json
hack/legacy_fill_db/out/output.html
hack/go-licenses

View File

@ -77,15 +77,20 @@ env BUILD_IN_DOCKER=y \
"out/docker-machine-driver-kvm2-${RPM_VERSION}-${RPM_REVISION}.x86_64.rpm"
# check if 'commit: <commit-id>' line contains '-dirty' commit suffix
BUILT_VERSION=$("out/minikube-$(go env GOOS)-$(go env GOARCH)" version)
echo ${BUILT_VERSION}
BUILT_VERSION="$(out/minikube-$(go env GOOS)-$(go env GOARCH) version)"
echo "$BUILT_VERSION"
# Extract commit hash from the correct line
COMMIT=$(echo "$BUILT_VERSION" | grep '^commit:' | awk '{print $2}')
COMMIT=$(echo ${BUILT_VERSION} | grep 'commit:' | awk '{print $2}')
if (echo ${COMMIT} | grep -q dirty); then
echo "'minikube version' reports dirty commit: ${COMMIT}"
if echo "$COMMIT" | grep -q dirty; then
echo "'minikube version' reports dirty commit: $COMMIT"
echo "------------------------------------------------------------------------"
echo "The following uncommitted changes are causing the build to be dirty:"
git status --porcelain
echo "------------------------------------------------------------------------"
echo "To fix this, commit or stash the above changes."
exit 1
fi
# Don't upload temporary copies, avoid unused duplicate files in the release storage
rm -f out/minikube-linux-x86_64
rm -f out/minikube-linux-i686