forked from neoclide/coc.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·56 lines (54 loc) · 1.72 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
#!/bin/sh
set -e
set -x
git add package.json history.md
tag=v$(json -f package.json version)
git commit -a -m "Release $tag" &> /dev/null
rm -rf build
webpack
mkdir .release
cp -r bin build autoload package.json plugin data Readme.md doc history.md .release
git checkout release
cp -r .release/* .
git add .
git commit -a -m "Release $tag"
git tag -a "$tag" -m "Release $tag"
git push
git push --tags
## upload assets
cd ./build
tar -zcf coc.tar.gz index.js
zip coc.zip index.js
declare -a files=("coc.zip" "coc.tar.gz")
GH_API="https://api.github.com"
GH_REPO="$GH_API/repos/neoclide/coc.nvim"
GH_TAGS="$GH_REPO/releases/tags/$tag"
AUTH="Authorization: token $GITHUB_API_TOKEN"
# Validate token.
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; }
# Create release
echo "Creating release for $tag"
curl -X POST -H "Authorization: token $GITHUB_API_TOKEN" \
-H "Content-Type: application/json" \
--data "{\"tag_name\":\"$tag\"}" \
"$GH_REPO/releases"
# Read asset tags.
response=$(curl -sH "$AUTH" $GH_TAGS)
# Get ID of the asset based on given filename.
eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
[ "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response" | awk 'length($0)<100' >&2; exit 1; }
# Upload asset
for filename in "${files[@]}"
do
GH_ASSET="https://uploads.github.com/repos/neoclide/coc.nvim/releases/$id/assets?name=$filename"
echo "Uploading $filename"
curl -X POST -H "Authorization: token $GITHUB_API_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$filename" \
$GH_ASSET
done
rm coc.zip coc.tar.gz
cd ..
git checkout master
rm -rf .release
nvim -c 'helptags doc|q'