forked from cloud-atlas-ai/obsidian-ics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·62 lines (50 loc) · 1.48 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
#!/bin/bash
set -euo pipefail
if [ "$#" -ne 2 ]; then
echo "Must provide exactly two arguments."
echo "First one must be the new version number."
echo "Second one must be the minimum obsidian version for this release."
echo ""
echo "Example usage:"
echo "./release.sh 0.3.0 0.11.13"
echo "Exiting."
exit 1
fi
if [[ $(git status --porcelain) ]]; then
echo "Changes in the git repo."
echo "Exiting."
exit 1
fi
NEW_VERSION=$1
MINIMUM_OBSIDIAN_VERSION=$2
echo "Updating to version ${NEW_VERSION} with minimum obsidian version ${MINIMUM_OBSIDIAN_VERSION}"
read -p "Continue? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Updating package.json"
TEMP_FILE=$(mktemp)
jq ".version |= \"${NEW_VERSION}\"" package.json > "$TEMP_FILE" || exit 1
mv "$TEMP_FILE" package.json
echo "Updating manifest.json"
TEMP_FILE=$(mktemp)
jq ".version |= \"${NEW_VERSION}\" | .minAppVersion |= \"${MINIMUM_OBSIDIAN_VERSION}\"" manifest.json > "$TEMP_FILE" || exit 1
mv "$TEMP_FILE" manifest.json
echo "Updating versions.json"
TEMP_FILE=$(mktemp)
jq ". += {\"${NEW_VERSION}\": \"${MINIMUM_OBSIDIAN_VERSION}\"}" versions.json > "$TEMP_FILE" || exit 1
mv "$TEMP_FILE" versions.json
read -p "Create git commit, tag, and push? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git add -A .
git commit -m"Update to version ${NEW_VERSION}"
git tag "${NEW_VERSION}"
git push
git push --tags
fi
else
echo "Exiting."
exit 1
fi