From 8511edaaab3856d4c61b090c92e11c0cab4ff924 Mon Sep 17 00:00:00 2001 From: Weston Pace Date: Thu, 23 May 2024 09:11:43 -0700 Subject: [PATCH] fix: get the last stable release before we've added a new tag (#1320) I tried to do a stable release and it failed with: ``` Traceback (most recent call last): File "/home/runner/work/lancedb/lancedb/ci/check_breaking_changes.py", line 20, in commits = repo.compare(args.base, args.head).commits ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/github/Repository.py", line 1133, in compare headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/compare/{base}...{head}", params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/github/Requester.py", line 548, in requestJsonAndCheck return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/github/Requester.py", line 609, in __check raise self.createException(status, responseHeaders, data) github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/commits/commits#compare-two-commits"} ``` I believe the problem is that we are calculating the `LAST_STABLE_RELEASE` after we have run bump version and so the newly created tag is in the list of tags we search and it is the most recent one and so it gets included as `LAST_STABLE_RELEASE`. Then, the call to github fails because we haven't pushed the tag yet. This changes the logic to grab `LAST_STABLE_RELEASE` before we create any new tags. --- ci/bump_version.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/bump_version.sh b/ci/bump_version.sh index 20d792d1..1b3311c8 100644 --- a/ci/bump_version.sh +++ b/ci/bump_version.sh @@ -43,7 +43,9 @@ if [[ $RELEASE_TYPE == 'stable' ]]; then fi # Validate that we have incremented version appropriately for breaking changes -LAST_STABLE_RELEASE=$(git tag --sort='version:refname' | grep ^$TAG_PREFIX | grep -v beta | python $SELF_DIR/semver_sort.py $TAG_PREFIX | tail -n 1) +NEW_TAG=$(git describe --tags --exact-match HEAD) +NEW_VERSION=$(echo $NEW_TAG | sed "s/^$TAG_PREFIX//") +LAST_STABLE_RELEASE=$(git tag --sort='version:refname' | grep ^$TAG_PREFIX | grep -v beta | grep -vF "$NEW_TAG" | python $SELF_DIR/semver_sort.py $TAG_PREFIX | tail -n 1) LAST_STABLE_VERSION=$(echo $LAST_STABLE_RELEASE | sed "s/^$TAG_PREFIX//") -NEW_VERSION=$(git describe --tags --exact-match HEAD | sed "s/^$TAG_PREFIX//") + python $SELF_DIR/check_breaking_changes.py $LAST_STABLE_RELEASE $HEAD_SHA $LAST_STABLE_VERSION $NEW_VERSION