mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
CICD: Add Script to Find the Changeset ID for a CICD Release Number.
Add a script that finds the changeset ID in the subsurface repository that a given CICD release was built from. The option '-c' can be used to check out the changeset, if one is found. Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
parent
ee8b37cc6e
commit
d49092ac70
1 changed files with 55 additions and 0 deletions
55
scripts/get-changeset-id.sh
Executable file
55
scripts/get-changeset-id.sh
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# find the changeset id for a given CICD release number
|
||||||
|
# and optionally checkout the resulting changeset
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# we ignore the base version here - all that is expected is the 'patch' part of the version
|
||||||
|
|
||||||
|
# little silly helper functions
|
||||||
|
croak() {
|
||||||
|
echo "$0: $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
croak_usage() {
|
||||||
|
croak "Usage: $0 <patch_version_number> [-c]"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -gt 2 ]] ; then croak_usage ; fi
|
||||||
|
CICD_VERSION=$1
|
||||||
|
if [[ $# -eq 2 ]] ; then
|
||||||
|
if [[ $2 != "-c" ]] ; then croak_usage ; fi
|
||||||
|
DO_CHECKOUT=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# figure out where we are in the file system
|
||||||
|
pushd . &> /dev/null
|
||||||
|
cd "$(dirname "$0")/../"
|
||||||
|
pushd . &> /dev/null
|
||||||
|
|
||||||
|
if [ ! -d "./nightly-builds" ] ; then
|
||||||
|
git clone https://github.com/subsurface/nightly-builds &> /dev/null || croak "failed to clone nightly-builds repo"
|
||||||
|
fi
|
||||||
|
cd nightly-builds
|
||||||
|
git fetch &> /dev/null
|
||||||
|
|
||||||
|
BUILD_SHA=""
|
||||||
|
BUILD_BRANCHES=$(git branch -a --sort=-committerdate --list origin/branch-for-\* | cut -d/ -f3)
|
||||||
|
for BUILD_BRANCH in $BUILD_BRANCHES ; do
|
||||||
|
git checkout $BUILD_BRANCH &> /dev/null
|
||||||
|
if [[ $(<./latest-subsurface-buildnumber) == $CICD_VERSION ]]; then
|
||||||
|
BUILD_SHA=$(cut -d- -f 3 <<< "$BUILD_BRANCH")
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
popd &> /dev/null
|
||||||
|
|
||||||
|
printf '%s' "$BUILD_SHA"
|
||||||
|
|
||||||
|
if [[ "$DO_CHECKOUT" == "1" && $BUILD_SHA != "" ]]; then
|
||||||
|
git checkout $BUILD_SHA &> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd &> /dev/null
|
Loading…
Add table
Add a link
Reference in a new issue