Skip to content

Commit

Permalink
make release tag discovery more robust (#2170)
Browse files Browse the repository at this point in the history
### Ticket
closes #2169

### Problem description
Current git stansa `git describe --tags --abbrev=0` can pick up tags
from personal dev branches, which will results in empty
TTMLIR_VERSION_MAJOR/TTMLIR_VERSION_MINOR defs and a broken build.

### What's changed
Final change is to add a glob filter that will select the latest tag
matching `v<digit>*.<digit>*`, which is compatible with our current
release tag format but should also reduce the probability that a
personal dev tag gets picked up.

Note that using `git tag --merged main ...` was promising in local
builds but seems problematic in CI which uses detached head clones.

### Checklist
Tested against multiple tags in a dev branch and observed a CI run
succeed with the latest changes.
  • Loading branch information
vroubtsovTT authored Feb 14, 2025
1 parent 7029de6 commit 2163da7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-tt-mlir-action/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ runs:
- name: Get Latest Tag and Version
shell: bash
run: |
latest_tag=$(git describe --tags --abbrev=0)
latest_tag=$(git describe --tags --match 'v[0-9]*.[0-9]*' --abbrev=0)
latest_tag=${latest_tag#v}
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
commit_count=$(git rev-list ${{ env.latest_tag }}..HEAD --count)
Expand Down
5 changes: 3 additions & 2 deletions cmake/modules/TTMLIRVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# get the latest tag from Git
# get the latest tag from git matching 'v<major>.<minor>' format
# (note: matching a glob(7) pattern, not a regex)
execute_process(
COMMAND git describe --tags --abbrev=0
COMMAND git describe --tags --match v[0-9]*.[0-9]* --abbrev=0
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down

0 comments on commit 2163da7

Please sign in to comment.