forked from MyEtherWallet/MyEtherWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·51 lines (46 loc) · 1.6 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
#!/bin/sh
RELEASE="$1"
GITHUB_TOKEN="$2"
REPO="$3"
CHANGELOG=`awk -v version="$RELEASE" '/### Release / {printit = $3 == version}; printit;' 'CHANGELOG.md'`
mkdir release
cd dist; zip -r ../release/MyEtherWallet-$RELEASE.zip *; cd ..
cd chrome-extension; zip -r ../release/MEW-CX-$RELEASE.zip *; cd ..
if [ -n "$4" ]; then
for f in release/*; do
gpg --output $f.sig --detach-sig $f
done
fi
sha256sum ./release/MyEtherWallet-$RELEASE.zip > ./release/MyEtherWallet-$RELEASE-CHECKSUM-SHA256
sha256sum ./release/MEW-CX-$RELEASE.zip > ./release/MEW-CX-$RELEASE-CHECKSUM-SHA256
GH_API="https://api.github.com"
GH_REPO="$GH_API/repos/$REPO"
AUTH="Authorization: token ${GITHUB_TOKEN}"
GH_TAGS="$GH_REPO/releases/tags/$RELEASE"
payload=$(
jq --null-input \
--arg tag "$RELEASE" \
--arg name "MyEtherWallet $RELEASE" \
--arg body "$CHANGELOG" \
'{ tag_name: $tag, name: $name, body: $body, draft: false }'
)
response=$(
curl -H "$AUTH" \
--fail \
--silent \
--location \
--data "$payload" \
"https://api.github.com/repos/${REPO}/releases"
)
upresponse=$(curl -sH "$AUTH" $GH_TAGS)
eval $(echo "$upresponse" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
[ "$id" ] || { echo "Error: Failed to get release id for tag: $RELEASE"; echo "$upresponse" | awk 'length($0)<100' >&2; exit 1; }
for file in ./release/*; do
curl -H "$AUTH" \
--header "Content-Type: application/octet-stream" \
--data-binary "@$file" \
--fail \
--silent \
--location \
"https://uploads.github.com/repos/${REPO}/releases/$id/assets?name=$(basename $file)"
done