-
Notifications
You must be signed in to change notification settings - Fork 15
/
release.sh
executable file
·122 lines (99 loc) · 2.77 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -e
set -o pipefail
pause() {
read -r -n 1 -s -p 'Press any key to continue. . .'
echo
}
run() {
echo "Running: $*" >&2
while :; do
local status=0
bash -c "$*" || status=$?
[[ $status == 0 ]] && break
echo "Failed" >&2
read -r -n 1 -s -p 'Press any key to retry or Ctrl+C to exit'
done
}
on_close() {
echo "module.exports = require('./src/extension')" > main.js # revert
}
trap on_close EXIT
echo update readme
pause
if ! [ -z "$(git status --porcelain)" ]; then
echo 'git working tree not clean'
exit 1
fi
run git push --tags origin master --dry-run
if grep -R -n -E '\s$' src web/src; then
echo 'trailing whitespace found'
exit 1
fi
run npx vsce verify-pat
: ''
run npx ncu -u -x '@types/vscode'
run npm i
pushd web
run npx ncu -u -x '@vscode-elements/elements'
run npm i
popd
run git add package.json package-lock.json web/package.json web/package-lock.json
git commit -m 'dependencies upgrade' ||:
echo 'deps upgraded'
pause
# '
pushd web
run npm run build
popd
rm web-dist/index.html
echo -e '\nBuilding main bundle:'
run npx esbuild src/extension.js --bundle --platform=node --outfile=main.js --external:vscode
echo built. manual tests:
pause
GIT_LOG__GRAPH_MODE=production vscodium --extensionDevelopmentPath="$PWD" --disable-extensions
pause
pause
run git fetch
changes=$(git log --reverse "$(git describe --tags --abbrev=0)".. --pretty=format:"%h___%B" |grep . |sed -E 's/^([0-9a-f]{6,})___(.)/- [`\1`](https:\/\/github.com\/phil294\/GitLG\/commit\/\1) \U\2/')
echo edit changelog
pause
changes=$(micro <<< "$changes")
[ -z "$changes" ] && exit 1
echo changes:
echo "$changes"
version=$(npm version patch --no-git-tag-version)
echo version: $version
pause
sed -i $'/<!-- CHANGELOG_PLACEHOLDER -->/r'<(echo $'\n### '${version} $(date +"%Y-%m-%d")$'\n\n'"$changes") CHANGELOG.md
run git add README.md CHANGELOG.md package.json
run git commit -m "$version"
run git tag "$version"
echo 'patched package.json version patch, updated changelog, committed, tagged'
pause
run npx vsce package
vsix_file=$(ls -tr git-log--graph-*.vsix* |tail -1)
mv "$vsix_file" vsix-out/"$vsix_file"
vsix_file=vsix-out/"$vsix_file"
echo $vsix_file
run xdg-open "${vsix_file@Q}"
ls -hltr vsix-out
ls -hltr
echo 'check vsix package before publish'
pause
pause
run npx vsce publish
echo 'vsce published'
pause
run npx ovsx publish "$vsix_file" -p "$(cat ~/.open-vsx-access-token)"
echo 'ovsx published'
pause
run git push --tags origin master
if [[ -z $version || -z $changes || -z $vsix_file ]]; then
echo version/changes empty
exit 1
fi
echo 'will create github release'
pause
run gh release create "$version" --target master --title "$version" --notes "${changes@Q}" --verify-tag "${vsix_file@Q}"
echo 'github release created'