-
Notifications
You must be signed in to change notification settings - Fork 1
/
gh-release.sh
58 lines (53 loc) · 1.56 KB
/
gh-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
#!/bin/bash
# How to?
# https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
# git config --global github .token YOUR_TOKEN
version=$1
text=$2
branch=$(git rev-parse --abbrev-ref HEAD)
token=$(git config --global github.token)
USER="Holo-Host"
REPO="dummy-dna"
generate_post_data()
{
cat <<EOF
{
"tag_name": "$version",
"target_commitish": "$branch",
"name": "v$version",
"body": "$text",
"draft": true,
"prerelease": false
}
EOF
}
echo "Create release $version for repo: $USER/$REPO branch: $branch"
response=$(
curl --fail \
--netrc \
--silent \
--location \
--data "$(generate_post_data)" \
"https://api.github.com/repos/${USER}/${REPO}/releases?access_token=$token"
)
upload_url="$(echo "$response" | jq -r .upload_url | sed -e "s/{?name,label}//")"
happ_file='test.happ'
curl --netrc \
-H "Authorization: token $token" \
-H "Content-Type: $(file -b --mime-type $happ_file)" \
--data-binary "@$happ_file" \
"$upload_url?name=$(basename "$happ_file")"
dna_file='test.dna'
curl --netrc \
-H "Authorization: token $token" \
-H "Content-Type: $(file -b --mime-type $dna_file)" \
--data-binary "@$dna_file" \
"$upload_url?name=$(basename "$dna_file")"
for NAME in alternate-happ-configs; do
alternate_happ_file="alternate-happ-configs/$NAME/test-$NAME.happ"
curl --netrc \
-H "Authorization: token $token" \
-H "Content-Type: $(file -b --mime-type $happ_file)" \
--data-binary "@$happ_file" \
"$upload_url?name=$(basename "$happ_file")"
done