This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.release.sh
executable file
·78 lines (59 loc) · 2.38 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
73
74
75
76
77
78
#!/bin/zsh
# ALFRED WORKFLOW RELEASE
# -----------------------
# -----------------------
# new version number
# -----------------------
# prompt for version
lastVersion=$(plutil -extract version xml1 -o - info.plist | sed -n 4p | cut -d">" -f2 | cut -d"<" -f1)
echo "Last Version: $lastVersion"
echo -n "Next Version: "
read nextVersion
echo ""
# Close Alfred Prefs to avoid conflicts
osascript -e 'tell application "Alfred Preferences" to if it is running then quit'
# insert new version number
plutil -replace version -string "$nextVersion" info.plist
# Lint
cd "$(dirname "$0")"
markdownlint --fix *.md
markdownlint --fix docs/*.md
# -----------------------
# clean info.plist
# -----------------------
# bkp info.plist
cp -v info.plist info-original.plist
# list of all variables to be excluded
excludedVars=$(plutil -extract variablesdontexport json -o - info.plist | tr -d "[]\"" | tr "," "\n")
# remove from info.plist
echo "$excludedVars" | tr "\n" "\0" | xargs -0 -I § plutil -replace variables.§ -string "" info.plist
# report excluded number
exclusionNo=$(echo $excludedVars | wc -l | tr -d " ")
echo "Removed $exclusionNo variables flagged as 'no export' removed from 'info.plist'."
# -----------------------
# compile .alfredworkflow
# -----------------------
# remove any potentially existing leftover workflow file
mv -fv *.alfredworkflow ~/.trash
# zip
workflowName=$(plutil -extract name xml1 -o - info.plist | sed -n 4p | cut -d">" -f2 | cut -d"<" -f1)
workflowName=$(echo $workflowName | tr " " "-")
zip --quiet -r "$workflowName.alfredworkflow" . -x ".git/*" ".github/*" "documentation/*" ".release.sh" ".gitignore" "info-original.plist" ".release-plist-edit.js" "README.md" ".DS_Store" "*.alfredworkflow"
echo "new $workflowName.alfredworkflow file created."
# restore original
mv -fv info.plist ~/.trash
mv -v info-original.plist info.plist
echo ""
# -----------------------
# git
# -----------------------
# 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
git add -A
git commit -m "release $nextVersion"
git pull
git push
# trigger the release action
git tag "$nextVersion"
git push origin --tags