Skip to content

Commit

Permalink
support git-less version default
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jun 1, 2022
1 parent 1612449 commit 40677b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions build.go/version.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/usr/bin/env sh

version="local-$(date +%Y%m%dT%H:%M:%S)"

if [ -z "$CI" ] ; then
# outside of CI
ref=$(git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD)
version="${ref}"-$(git log -1 --format=%h)-$(date +%Y%m%dT%H:%M:%S)
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] ; then
# valid git repo
ref=$(git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD)
version="${ref}"-$(git log -1 --format=%h)-$(date +%Y%m%dT%H:%M:%S)
fi
else
# inside CI (gh actions)
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
Expand Down

0 comments on commit 40677b8

Please sign in to comment.