-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.sh
executable file
·67 lines (53 loc) · 1.68 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -e
[[ $1 =~ ^[0-9.]+$ ]] || { echo "First arg should be version" >&2; exit 1; }
[[ $2 =~ ^(stable|exp)$ ]] || { echo "Invalid channel (stable|exp)." >&2; exit 1; }
version=$1
channel=$2
docker_image="rfvgyhn/factorio"
build_args=""
commit_message="upgrade $channel to $version"
tags=("latest")
exp() {
sed -i "s/^exp.*$/exp: $version/" version.txt
sed -i "s|^\[7\].*|[7]: https://img.shields.io/badge/v-$version-blue|" README.md
sed -i "s|^\[10\].*|[10]: https://img.shields.io/docker/image-size/$docker_image/$version-experimental|" README.md
sed -i "s|^\[11\].*|[11]: https://img.shields.io/badge/v-$version-blue|" README.md
tags+=("$version-experimental")
}
stable() {
sed -i "s/^stable.*$/stable: $version/" version.txt
sed -i "s|^\[7\].*|[7]: https://img.shields.io/badge/v-$version-blue|" README.md
sed -i "s|^\[9\].*|[9]: https://img.shields.io/badge/v-$version-blue|" README.md
tags+=("stable" "$version")
}
build() {
docker build \
--build-arg VERSION="$version" \
--build-arg CREATED=$(date -u -Iseconds) \
--build-arg SOURCE=$(git config --get remote.origin.url) \
--build-arg REVISION=$(git rev-parse --short HEAD) \
${build_args} \
-t "$docker_image:latest" .
}
tag() {
docker tag "$docker_image" "$docker_image:$1"
}
push() {
docker push "$docker_image:$1"
}
echo "Version: $version"
echo "Channel: $channel"
if [[ $channel = "exp" ]]; then
exp
elif [[ $channel = "stable" ]]; then
stable
fi
git add version.txt README.md
git commit -m "$commit_message" || true
build
for t in ${tags[@]}; do
tag "$t"
push "$t"
done
docker pushrm "$docker_image" # https://github.com/christian-korneck/docker-pushrm