generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrelease.sh
executable file
·50 lines (40 loc) · 1.68 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
#!/bin/bash
set -e
# cd to git root https://stackoverflow.com/a/38843585
r=$(git rev-parse --git-dir) && r=$(cd "$r" && pwd)/ && cd "${r%%/.git/*}"
if [[ ! -f "./manifest.json" ]] ; then
echo "manifest.json does not exist yet"
return
fi
if [[ ! -f "./.github/workflows/release.yml" ]] ; then
echo "/.github/workflows/release.yml does not exist yet"
return
fi
# get version number from the manifest of the latest release
repoURL=$(git remote -v | grep [email protected] | grep fetch | head -n1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/https:\/\//' -e 's/\.git//' )
manifestURL="$repoURL"/releases/latest/download/manifest.json
lastVersion=$(curl -sL "$manifestURL" | grep "version" | cut -d\" -f4)
echo "last version: $lastVersion"
# Ask for new version number
echo -n "next version: "
read nextVersion
# set version number in `manifest.json`
sed -E -i -e "s/\"version\".*/\"version\": \"$nextVersion\",/" "manifest.json"
# set version number in `package.json`
sed -E -i -e "s/^ \"version\".*/ \"version\": \"$nextVersion\",/" "package.json"
# add version number in `versions.json`, assuming same compatibility
cat "versions.json" | egrep -v "^$" | grep -v "}" | sed -e '$ d' > temp
minObsidianVersion=$(cat "versions.json" | egrep -v "^$" | grep -v "}" | tail -n1 | cut -d\" -f4)
echo " \"$lastVersion\": \"$minObsidianVersion\"," >> temp
echo " \"$nextVersion\": \"$minObsidianVersion\"" >> temp
echo "}" >> temp
mv temp versions.json
echo "It's time to pause and check. All ready? Press ENTER to continue."
read
# push the manifest and versions JSONs
git add -A
git commit -m "version bump to $nextVersion"
git push
# trigger the release action
git tag "$nextVersion"
git push origin --tags