-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpublish-github-release.sh
executable file
·54 lines (45 loc) · 1.04 KB
/
publish-github-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
#!/usr/bin/env sh
set -eu
owner="JetBrains"
repo="terraform-provider-teamcity"
version=v0.0.${BUILD_NUMBER:-dev}
release=$(cat <<EOF
{
"tag_name": "$version",
"name": "$version",
"draft": true
}
EOF
)
echo "Creating a release draft..."
response=$(curl -s -S \
-X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/repos/$owner/$repo/releases \
-d "$release"
)
id=$(echo $response | jq '.id')
echo "id=$id"
cd build
for file in *
do
if [ -f "$file" ] # skip subdirectories
then
mime=$(file --mime-type -b $file)
echo "Uploading $file..."
curl -s -S \
-X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: $mime" \
"https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$file" \
--data-binary @$file
fi
done
echo "Publishing the release..."
curl -s -S -o /dev/null \
-X PATCH \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/repos/$owner/$repo/releases/$id \
-d '{"draft":false}'
unset GITHUB_TOKEN
echo "Done."