mirror of
https://github.com/genuinetools/reg.git
synced 2024-08-21 14:20:23 -04:00
60 lines
2.1 KiB
Text
60 lines
2.1 KiB
Text
![]() |
#!/usr/bin/env bash
|
||
|
|
||
|
ENGINE_DIR=$1
|
||
|
VERSION=$2
|
||
|
|
||
|
[[ $# < 2 ]] && echo 'not enough args' && exit 1
|
||
|
|
||
|
DATE_COMMAND="date"
|
||
|
if [[ $(uname) -eq "Darwin" ]]; then
|
||
|
DATE_COMMAND="docker run --rm alpine date"
|
||
|
fi
|
||
|
|
||
|
GIT_COMMAND="git -C $ENGINE_DIR"
|
||
|
origVersion="$VERSION"
|
||
|
rpmVersion="$VERSION"
|
||
|
rpmRelease=3
|
||
|
|
||
|
# rpmRelease versioning is as follows
|
||
|
# Docker 18.01.0-ce: version=18.01.0.ce, release=3
|
||
|
# Docker 18.01.0-ce-tp1: version=18.01.0.ce, release=0.1.tp1
|
||
|
# Docker 18.01.0-ce-beta1: version=18.01.0.ce, release=1.1.beta1
|
||
|
# Docker 18.01.0-ce-rc1: version=18.01.0.ce, release=2.1.rc1
|
||
|
# Docker 18.01.0-ce-cs1: version=18.01.0.ce.cs1, release=1
|
||
|
# Docker 18.01.0-ce-cs1-rc1: version=18.01.0.ce.cs1, release=0.1.rc1
|
||
|
# Docker 18.01.0-ce-dev nightly: version=18.01.0.ce, release=0.0.YYYYMMDD.HHMMSS.gitHASH
|
||
|
|
||
|
if [[ "$rpmVersion" =~ .*-tp[0-9]+$ ]]; then
|
||
|
tpVersion=${rpmVersion#*-tp}
|
||
|
rpmVersion=${rpmVersion%-tp*}
|
||
|
rpmRelease="0.${tpVersion}.tp${tpVersion}"
|
||
|
elif [[ "$rpmVersion" =~ .*-beta[0-9]+$ ]]; then
|
||
|
betaVersion=${rpmVersion#*-beta}
|
||
|
rpmVersion=${rpmVersion%-beta*}
|
||
|
rpmRelease="1.${betaVersion}.beta${betaVersion}"
|
||
|
elif [[ "$rpmVersion" =~ .*-rc[0-9]+$ ]]; then
|
||
|
rcVersion=${rpmVersion#*-rc}
|
||
|
rpmVersion=${rpmVersion%-rc*}
|
||
|
rpmRelease="2.${rcVersion}.rc${rcVersion}"
|
||
|
fi
|
||
|
|
||
|
DOCKER_GITCOMMIT=$($GIT_COMMAND rev-parse --short HEAD)
|
||
|
if [ -n "$($GIT_COMMAND status --porcelain --untracked-files=no)" ]; then
|
||
|
DOCKER_GITCOMMIT="$DOCKER_GITCOMMIT-unsupported"
|
||
|
fi
|
||
|
|
||
|
# if we have a "-dev" suffix or have change in Git, let's make this package version more complex so it works better
|
||
|
if [[ "$rpmVersion" == *-dev ]] || [ -n "$($GIT_COMMAND status --porcelain)" ]; 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')"
|
||
|
# gitVersion is now something like '20150128.112847.17e840a'
|
||
|
rpmVersion="0.${gitDate}-${gitCommit}"
|
||
|
rpmRelease="0"
|
||
|
origVersion="0.${gitDate}-${gitCommit}"
|
||
|
fi
|
||
|
|
||
|
# Replace any other dashes with periods
|
||
|
rpmVersion="${rpmVersion//-/.}"
|
||
|
echo $rpmVersion $rpmRelease $DOCKER_GITCOMMIT $origVersion
|