-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
executable file
·49 lines (37 loc) · 1007 Bytes
/
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
#!/bin/bash
# Usage: release-server.sh <version>
set -e
# Check if version is specified
if [ -z "$1" ]; then
echo "Usage: release.sh <version>"
exit 1
fi
# Check if version is valid
if ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: $1, should be in format x.y.z"
exit 1
fi
# 获取version
version=$1
# 获取 major.minor.patch
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3)
# Check if version is already released
if git tag | grep -q "v$version"; then
echo "Version v$version is already released"
exit 1
fi
# Create tag
git tag -a "v$version" -m "v$version"
# Push tag
git push origin "v$version"
# 检测是否登录docker hub
docker login
# 编译并发布镜像
docker buildx build --platform linux/amd64,linux/arm64 \
-t gcslaoli/go-oss:latest \
-t gcslaoli/go-oss:$major \
-t gcslaoli/go-oss:$major.$minor \
-t gcslaoli/go-oss:$major.$minor.$patch \
--push .