-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpush_release.sh
More file actions
executable file
·33 lines (27 loc) · 969 Bytes
/
push_release.sh
File metadata and controls
executable file
·33 lines (27 loc) · 969 Bytes
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
#!/usr/bin/env bash
set -e
if [ "$#" -ne 2 ]; then
echo "Some parameters [GIT_TAG, GIT_REPO] were not provided"
exit
fi
GIT_TAG=$1
GIT_REPO=$2
CREATE_RELEASE_DATA='{
"tag_name": "'"${GIT_TAG}"'",
"target_commitish": "main",
"name": "'"${GIT_TAG}"'",
"body": "release-'"${GIT_TAG}"'",
"draft": false,
"prerelease": false
}'
echo "Creating a new release: $GIT_TAG branch: main"
RESPONSE=$(curl -s --data "${CREATE_RELEASE_DATA}" -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/$GIT_REPO/releases")
ASSET_UPLOAD_URL=$(echo "$RESPONSE" | jq -r .upload_url | cut -d '{' -f1)
if [ -z "$ASSET_UPLOAD_URL" ]; then
echo ${RESPONSE}
exit 1
fi
for FILE in toCopy/*; do
echo "Uploading asset: $FILE to url: $ASSET_UPLOAD_URL?name=${FILE}"
curl -s --data-binary @${FILE} -H "Content-Type: application/octet-stream" -H "Authorization: token ${GITHUB_TOKEN}" -X POST "$ASSET_UPLOAD_URL?name=$(basename ${FILE})"
done