-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathrelease.sh
32 lines (25 loc) · 1.08 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
#!/bin/bash
if [ "$GITHUB_REPOSITORY" != "IRE-Mudlet-Mapping/ire-mapping-script" ]; then
echo "Not on main repo, aborting"
exit 0
fi
currentScriptSha1=$(grep -v "local newversion = " "${GITHUB_WORKSPACE}/gh-pages/downloads/mudlet-mapper.xml" | sha1sum | cut -d " " -f1)
newScriptSha1=$(grep -v "local newversion = " "${GITHUB_WORKSPACE}/master/mudlet-mapper.xml" | sha1sum | cut -d " " -f1)
if [ "${currentScriptSha1}" = "${newScriptSha1}" ]; then
echo "No change in the script, aborting"
exit 0
fi
cd "${GITHUB_WORKSPACE}/gh-pages/downloads" || exit 1
cp "${GITHUB_WORKSPACE}/master/mudlet-mapper.xml" .
datePart=$(date +"%y.%-m")
lastDatePart=$(grep -o "^[0-9]*\.[0-9]*" version)
if [ "$lastDatePart" = "$datePart" ]; then
versionPart=$(($(grep -o "[0-9]*$" version) + 1))
else
versionPart=1
fi
version="$datePart.$versionPart"
sed -rbe "s/local newversion = \"developer\"/local newversion = \"$version\"/g" "mudlet-mapper.xml" > "mudlet-mapper.xml.tmp" && mv "mudlet-mapper.xml.tmp" "mudlet-mapper.xml"
echo "$version" > version
git commit -m"Release new version" .
git push --quiet