Skip to content

Commit

Permalink
add versions.sh to simplify inside and outside of CI version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed May 4, 2021
1 parent ef82735 commit b4a9c8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ RUN go get github.com/goreleaser/goreleaser@v${GORELEASER} && goreleaser -v

ADD coverage.sh /script/coverage.sh
ADD git-rev.sh /script/git-rev.sh
ADD version.sh /script/version.sh

RUN chmod +x /script/coverage.sh /script/git-rev.sh
RUN chmod +x /script/coverage.sh /script/git-rev.sh /script/version.sh
12 changes: 12 additions & 0 deletions build.go/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh

if [ -z "$CI" ] ; then
#outside of
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)
else
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
version=${ref}-${GITHUB_SHA:0:7}-$(date +%Y%m%dT%H:%M:%S)
fi

echo "$version"

0 comments on commit b4a9c8c

Please sign in to comment.