Coding Spirit

一位程序员,比较帅的那种

0%

GitHub REST API v3: Use Curl To Upload Artifact To Release

With OAuth2 Token Authentication

1
curl -H "Authorization: token <OAUTH-TOKEN>" https://api.github.com

Create A Release And Add An Artifact

1
2
3
4
5
6
7
8
9
10
11
12
# Create a new release and get upload url
upload_url=$(curl -s -H "Authorization: token $TOKEN" \
-d '{"tag_name":"'"$ARTIFACTS_BASE_NAME"'", "name":"'"$ARTIFACTS_BASE_NAME"'", "body":"'"$ARTIFACTS_BASE_NAME"'", "target_commitish":"'"$TARGET_BRANCH"'"}' \
"https://api.github.com/repos/$REPO/$TARGET_BRANCH" | jq -r '.upload_url')

upload_url="${upload_url%\{*}"

# Upload a tarball
curl -s -H "Authorization: token $TOKEN" \
-H "Content-Type: application/x-gzip" \
--data-binary @$ARTIFACTS_BASE_NAME.tar.gz \
"$upload_url?name=$ARTIFACTS_BASE_NAME.tar.gz&label=$ARTIFACTS_BASE_NAME.tar.gz"