-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag-release.sh
executable file
·50 lines (40 loc) · 1.29 KB
/
tag-release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -e
VERSION="$1"
if [ -z "$VERSION" ] || [ "$VERSION" = '-h' ] || [ "$VERSION" = '--help' ]
then
echo "usage: $0 version"
echo ' Create a tagged version release.'
echo
echo ' Modifies the Dockerfile to use a specific base image tag, creates a'
echo ' Git commit with message "Tag release version", tags the commit with'
echo ' tag version, and resets to the current commit.'
exit 1
fi
if git rev-parse "$VERSION" >/dev/null 2>&1
then
echo "Tag ${VERSION} already exists. If you wish to replace it, please delete"
echo 'it and run this script again.'
exit 2
fi
DOCKER_REGISTRY='https://hub.docker.com/v2'
DOCKER_IMAGE='openshift/origin-haproxy-router'
echo "Validating that upstream image ${DOCKER_IMAGE}:${VERSION} exists."
echo
if ! curl -sfL "${DOCKER_REGISTRY}/repositories/${DOCKER_IMAGE}/tags/${VERSION}/" -o /dev/null
then
echo "Tag ${VERSION} does not exist in the upstream image. Please specify"
echo 'a valid upstream image.'
exit 3
fi
sed "s/FROM.*/&:${VERSION}/" Dockerfile >Dockerfile.2
mv Dockerfile.2 Dockerfile
git add Dockerfile
git commit -qm "Tag version $VERSION"
git tag "$VERSION"
git show
git reset -q HEAD~
git checkout Dockerfile
echo
echo "Tag $VERSION created. You can now push it to origin with:"
echo " git push origin ${VERSION}"