-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathrelease_as_latest.sh
executable file
·66 lines (54 loc) · 1.71 KB
/
release_as_latest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -ex
VERSION="$1"
if [[ -z "$VERSION" ]]; then
echo "Usage: ./release_as_latest.sh <version>"
exit 1
fi
echo "Version: $VERSION"
IMAGE=sinusbot/docker
read -p "Pull from git? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]| ) ]] || [[ -z $REPLY ]]; then
git pull
fi
echo "Replacing version in files..."
sed -i '' "s|^SINUSBOT_VERSION=.*|SINUSBOT_VERSION=\"$VERSION\"|g" discord/install.sh
sed -i '' "s|^LABEL version.*|LABEL version=\"$VERSION\"|g" discord/Dockerfile
sed -i '' "s|^FROM sinusbot.*|FROM $IMAGE:$VERSION-discord|g" Dockerfile
sed -i '' "s|^LABEL version.*|LABEL version=\"$VERSION\"|g" Dockerfile
read -p "Show diff? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]) ]]; then
git diff
fi
read -p "Commit changes? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]| ) ]] || [[ -z $REPLY ]]; then
git add -A
git commit -m "v$VERSION"
git tag -a "v$VERSION" -m "v$VERSION"
fi
read -p "Push to git? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]| ) ]] || [[ -z $REPLY ]]; then
git push
git push --tags
fi
read -p "Build images? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]| ) ]] || [[ -z $REPLY ]]; then
docker pull debian:buster-slim
docker build --platform linux/amd64 -t "$IMAGE":discord discord
docker tag "$IMAGE":discord "$IMAGE":"$VERSION"-discord
docker build --platform linux/amd64 -t "$IMAGE":latest .
docker tag "$IMAGE":latest "$IMAGE":"$VERSION"
read -p "Push the builds to docker? (requires docker login) [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]| ) ]] || [[ -z $REPLY ]]; then
docker push "$IMAGE":"$VERSION"-discord
docker push "$IMAGE":discord
docker push "$IMAGE":"$VERSION"
docker push "$IMAGE":latest
fi
fi