forked from chrisgrieser/obsidian-divide-and-conquer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.release.sh
executable file
·72 lines (61 loc) · 2.19 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
63
64
65
66
67
68
69
70
71
72
#!/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
# Requirements
# - markdownlint
# - eslint
# ensure relevant files exist
if [[ ! -f "./manifest.json" ]] ; then
echo "manifest.json does not exist yet"
exit 1
fi
if [[ ! -f "./versions.json" ]] ; then
echo "versions.json does not exist yet"
exit 1
fi
if [[ ! -f "./package.json" ]] ; then
echo "package.json does not exist yet"
exit 1
fi
if [[ ! -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 ""
# Lint
cd "$(dirname "$0")" || exit 1
eslint . --fix --ext=ts # to not lint the main.js files
markdownlint --fix ./README.md
# 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