Adds git date plus git commit sha to static builds if the version being built for is a development version Output is similar to: `docker-18.02.0-ce-dev-20180120.170357-fa4fb35.tgz` Signed-off-by: Eli Uriegas <eli.uriegas@docker.com> Upstream-commit: 8a86c3a6a54760b19cd67854bf68e408bd2a17fb Component: packaging
26 lines
627 B
Bash
Executable File
26 lines
627 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
ENGINE_DIR=$1
|
|
VERSION=$2
|
|
|
|
if [ -z "$ENGINE_DIR" ] || [ -z "$VERSION" ]; then
|
|
echo 'usage: ./gen-static-ver ${ENGINE_DIR} ${VERSION}'
|
|
exit 1
|
|
fi
|
|
|
|
DATE_COMMAND="date"
|
|
if [[ $(uname) -eq "Darwin" ]]; then
|
|
DATE_COMMAND="docker run --rm alpine date"
|
|
fi
|
|
GIT_COMMAND="git -C $ENGINE_DIR"
|
|
|
|
staticVersion="$VERSION"
|
|
if [[ "$VERSION" == *-dev ]]; then
|
|
gitUnix="$($GIT_COMMAND log -1 --pretty='%at')"
|
|
gitDate="$($DATE_COMMAND --date "@$gitUnix" +'%Y%m%d.%H%M%S')"
|
|
gitCommit="$($GIT_COMMAND log -1 --pretty='%h')"
|
|
staticVersion="${VERSION}-${gitDate}-${gitCommit}"
|
|
fi
|
|
|
|
echo "$staticVersion"
|