Skip to content

Commit

Permalink
Refine version extraction from tag
Browse files Browse the repository at this point in the history
Depending on if we have commits afterwards or not, make sure the
'v' prefix is handled correctly.
  • Loading branch information
hzeller committed May 27, 2024
1 parent f3a3c03 commit dd551ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ jobs:
bazel-bin/bant/bant -V # Print version
# Version number: current tag dot number of commits after tagging.
# If at exactly a tag, that will be left as-is
VERSION=$(git describe --match=v* 2>/dev/null \
| sed 's/v\([^-]*\)-\([0-9]*\).*/\1-\2/')
OUT=bant-v${VERSION}-x86
| sed 's/v\([^-]*\)-\([0-9]*\)-.*/v\1-\2/')
OUT=bant-${VERSION}-x86
echo "OUT=${OUT}" >> $GITHUB_ENV
mkdir -p "${OUT}/bin"
Expand All @@ -226,7 +227,7 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 3 additions & 2 deletions scripts/create-workspace-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
version_from_git() {
set -o pipefail
git describe --match=v* 2>/dev/null \
| sed 's/v\([^-]*\)-\([0-9]*\).*/\1-\2/' 2>/dev/null
| sed 's/v\([^-]*\)-\([0-9]*\).*/\1-\2/' \
| sed 's/^v//'
}

version_from_module_bazel() {
awk '/module/ { in_module=1; }
/version/ { if (in_module) print $0; }
/)/ { in_module=0; }' $(dirname $0)/../MODULE.bazel \
| sed 's/.*version[ ]*=[ ]*"\([0-9.]*\)".*/\1/p;d'
| sed 's/.*version[ ]*=[ ]*"\([0-9.]*\)".*/\1/p;d'
}

# Get version from git including everything since last tag, but if that is
Expand Down

0 comments on commit dd551ab

Please sign in to comment.