-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathadd-version.sh
executable file
·78 lines (61 loc) · 1.82 KB
/
add-version.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
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: add-version url"
exit
fi
URL=$1
if [[ $URL =~ ^([^\?]+)(\?.+)?$ ]]; then
URL=${BASH_REMATCH[1]}
fi
if [[ $URL =~ builtin_shaders-(.+)\.zip$ ]]; then
VERSION=${BASH_REMATCH[1]}
else
echo "Invalid URL"
exit
fi
ZIP_FILENAME="builtin_shaders-${VERSION}.zip"
if [[ $VERSION =~ ^([0-9]+\.[0-9]+)\. ]]; then
MAJOR_BRANCH=${BASH_REMATCH[1]}
fi
LOCAL_BRANCH_COUNT=`git branch --list | grep "$MAJOR_BRANCH" | wc -l`
REMOTE_BRANCH_COUNT=`git branch -r | grep "origin/${MAJOR_BRANCH}" | wc -l`
git checkout master
git pull
if [ $LOCAL_BRANCH_COUNT -eq 1 ]; then
git checkout $MAJOR_BRANCH
elif [ $REMOTE_BRANCH_COUNT -eq 1 ]; then
git checkout -b $MAJOR_BRANCH "origin/${MAJOR_BRANCH}"
else
git checkout -b $MAJOR_BRANCH
fi
git pull
VERSIONS_FILENAME="VERSIONS.md"
echo -e "* Version ${VERSION}: ${URL}\n$(cat $VERSIONS_FILENAME)" > $VERSIONS_FILENAME
SORTED_VERSIONS="$(sort -Vru $VERSIONS_FILENAME)"
echo "${SORTED_VERSIONS}" > $VERSIONS_FILENAME
rm -Rf Shaders
curl $URL -o $ZIP_FILENAME
unzip $ZIP_FILENAME -d Shaders
rm $ZIP_FILENAME
SECONDARY_ZIP_FILENAME="Shaders/build/BuiltinShaders/builtin_shaders.zip"
if [ -f "$SECONDARY_ZIP_FILENAME" ]; then
mv $SECONDARY_ZIP_FILENAME $ZIP_FILENAME
rm -Rf Shaders
unzip $ZIP_FILENAME -d Shaders
rm $ZIP_FILENAME
fi
COMMIT_MESSAGE="Version ${VERSION}"
TAG_MESSAGE="${COMMIT_MESSAGE}"
git add --all
git commit -m "${COMMIT_MESSAGE}"
git push --set-upstream origin "${MAJOR_BRANCH}"
git tag -a "v${VERSION}" -m "${TAG_MESSAGE}"
git push --tags
git checkout master
VERSIONS_FILENAME="VERSIONS.md"
echo -e "* Version ${VERSION}: ${URL}\n$(cat $VERSIONS_FILENAME)" > $VERSIONS_FILENAME
SORTED_VERSIONS="$(sort -Vru $VERSIONS_FILENAME)"
echo "${SORTED_VERSIONS}" > $VERSIONS_FILENAME
git add --all
git commit -m "Updated ${VERSIONS_FILENAME}"
git push