This repository has been archived by the owner on Jan 18, 2025. It is now read-only.
generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.release.sh
executable file
·60 lines (51 loc) · 2.02 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
#!/bin/zsh
# Release Obsidian Plugin
# https://forum.obsidian.md/t/using-github-actions-to-release-plugins/7877
# https://marcus.se.net/obsidian-plugin-docs/publishing/release-your-plugin-with-github-actions
# ensure relevant files exist
if [[ ! -f "./manifest.json" ]] ; then
echo "manifest.json does not exist yet"
exit 1
elif [[ ! -f "./versions.json" ]] ; then
echo "versions.json does not exist yet"
exit 1
elif [[ ! -f "./package.json" ]] ; then
echo "package.json does not exist yet"
exit 1
elif [[ ! -f "./.github/workflows/release.yml" ]] ; then
echo "/.github/workflows/release.yml does not exist yet"
exit 1
fi
# Prompt for version number, if not entered
nextVersion="$*"
currentVersion=$(grep "version" "./manifest.json" | cut -d\" -f4)
echo "current version: $currentVersion"
echo -n " next version: "
if [[ -z "$nextVersion" ]]; then
read -r nextVersion
else
echo "$nextVersion"
fi
echo ""
# set version number in `manifest.json`
sed -E -i '' "s/\"version\".*/\"version\": \"$nextVersion\",/" "manifest.json"
sed -E -i '' "s/\"version\".*/\"version\": \"$nextVersion\",/" "package.json"
# add version number in `versions.json`, assuming same compatibility
grep -Ev "^$" "versions.json" | grep -v "}" | sed -e '$ d' > temp
minObsidianVersion=$(grep -Ev "^$" "versions.json" | grep -v "}" | tail -n1 | cut -d\" -f4)
# shellcheck disable=SC2129
echo " \"$currentVersion\": \"$minObsidianVersion\"," >> temp
echo " \"$nextVersion\": \"$minObsidianVersion\"" >> temp
echo "}" >> temp
mv temp versions.json
# update changelog
echo "- $(date +"%Y-%m-%d") release $nextVersion" > ./Changelog.md
git log --pretty=format:"- %ad%x09%s" --date=short | grep -Ev "minor$" | grep -Ev "patch$" | grep -Ev "typos?$" | grep -v "refactoring" | grep -v "Add files via upload" | grep -Ev "\tDelete" | grep -Ev "\tUpdate.*\.md" | sed -E "s/\t\+ /\t/g" >> ./Changelog.md
# push the manifest and versions JSONs
git add -A
git commit -m "release $nextVersion"
git pull
git push
# trigger the release action
git tag "$nextVersion"
git push origin --tags