File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,23 @@ PLATFORM=${PLATFORM:-}
1313VERSION=${VERSION:- $(git describe --match ' v[0-9]*' --dirty=' .m' --always --tags | sed ' s/^v//' 2>/ dev/ null || echo " unknown-version" )}
1414GITCOMMIT=${GITCOMMIT:- $(git rev-parse --short HEAD 2> / dev/ null || true)}
1515
16- if [ " $( uname) " = " Darwin" ]; then
17- # Using BSD date (macOS), which doesn't suppoort the --date option
18- # date -jf "<input format>" "<input value>" +"<output format>" (https://unix.stackexchange.com/a/86510)
19- BUILDTIME=${BUILDTIME:- $(TZ=UTC date -jf " %s" " ${SOURCE_DATE_EPOCH:- $(date +% s)} " +" %Y-%m-%dT%H:%M:%SZ" )}
20- else
21- # Using GNU date (Linux)
22- BUILDTIME=${BUILDTIME:- $(TZ=UTC date -u --date=" @${SOURCE_DATE_EPOCH:- $(date +% s)} " +" %Y-%m-%dT%H:%M:%SZ" )}
16+ # Try GNU date syntax first (Linux), fallback to BSD date syntax (macOS) if failed
17+ BUILDTIME_SET=false
18+ if [ -z " ${BUILDTIME:- } " ]; then
19+ # Try GNU date syntax
20+ TZ=UTC date -u --date=" @${SOURCE_DATE_EPOCH:- $(date +% s)} " +" %Y-%m-%dT%H:%M:%SZ" > /dev/null 2>&1 && {
21+ BUILDTIME=$( TZ=UTC date -u --date=" @${SOURCE_DATE_EPOCH:- $(date +% s)} " +" %Y-%m-%dT%H:%M:%SZ" )
22+ BUILDTIME_SET=true
23+ }
24+ fi
25+
26+ if [ -z " ${BUILDTIME:- } " ] && [ " $BUILDTIME_SET " = false ]; then
27+ # Fallback to BSD date syntax
28+ echo " GNU date syntax not supported, fallback to BSD date syntax"
29+ TZ=UTC date -jf " %s" " ${SOURCE_DATE_EPOCH:- $(date +% s)} " +" %Y-%m-%dT%H:%M:%SZ" > /dev/null 2>&1 && {
30+ BUILDTIME=$( TZ=UTC date -jf " %s" " ${SOURCE_DATE_EPOCH:- $(date +% s)} " +" %Y-%m-%dT%H:%M:%SZ" )
31+ BUILDTIME_SET=true
32+ }
2333fi
2434
2535case " $VERSION " in
You can’t perform that action at this time.
0 commit comments