-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·48 lines (40 loc) · 1.37 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
#!/bin/bash
VERSION=$1
TAG="v$VERSION"
if [[ -z $VERSION ]]; then
echo "ERROR: No version to release specified"
exit 1
fi
rx='^([0-9]+\.){0,2}(\*|[0-9]+)$'
if [[ $VERSION =~ $rx ]]; then
echo "INFO: Version $VERSION"
else
echo "ERROR: Version specified not valid: $VERSION"
exit 1
fi
if git rev-parse $TAG > /dev/null 2>&1; then
echo "ERROR: Version $VERSION already released"
exit 1
fi
if [[ `git branch --show-current` != "main" ]]; then
echo "ERROR: Not currently on main branch"
exit 1
fi
if [[ `git status --porcelain` ]]; then
echo "ERROR: There are local changes:"
git status --short
exit 1
fi
sed -i "s/VERSION = \"dev\"/\VERSION = \"$VERSION\"/" custom_components/switchbot_cloud/const.py
sed -i "s/ \"version\": \"0.0.0\",/ \"version\": \"$VERSION\",/" custom_components/switchbot_cloud/manifest.json
git add custom_components/switchbot_cloud/const.py
git add custom_components/switchbot_cloud/manifest.json
git commit --message "Release $VERSION"
git tag $TAG
git push origin $TAG
sed -i -E "s/VERSION = \".+\"/\VERSION = \"dev\"/" custom_components/switchbot_cloud/const.py
sed -i -E "s/ \"version\": \".+\",/ \"version\": \"0.0.0\",/" custom_components/switchbot_cloud/manifest.json
git add custom_components/switchbot_cloud/const.py
git add custom_components/switchbot_cloud/manifest.json
git commit --message "Prepare for next version"
git push origin