-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/github_actions/aws-actions/config…
…ure-aws-credentials-3
- Loading branch information
Showing
4 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ -z "$GITHUB_TOKEN" ]]; then | ||
echo "Set the GITHUB_TOKEN env variable." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$ASSET_NAME_PREFIX" ]]; then | ||
echo "Set the ASSET_NAME_PREFIX env variable." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$ASSET_DIR" ]]; then | ||
echo "Set the ASSET_DIR env variable." | ||
exit 1 | ||
fi | ||
|
||
VERSION=$1 | ||
if [[ -z "$VERSION" ]]; then | ||
echo "Set the VERSION parameter." | ||
exit 1 | ||
fi | ||
|
||
_DIR=$(dirname "$0") | ||
UPLOAD_URL=$($_DIR/get_draft_release.sh UPLOAD_URL) | ||
|
||
upload_asset() { | ||
local file=$1 | ||
local size=$2 | ||
local content_type=$3 | ||
echo "Uploading $file ($size bytes) to $UPLOAD_URL" | ||
curl \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Content-Length: $size"\ | ||
-H "Content-Type: $content_type" \ | ||
--data-binary @$file "$UPLOAD_URL?name=$(basename $file)" | ||
} | ||
|
||
EXTENSION=".zip" | ||
FILE=$ASSET_DIR/$ASSET_NAME_PREFIX$VERSION$EXTENSION | ||
# Skip if zip files do not exist (some extensions do not generate examples in zip format) | ||
if [[ ! -f "$FILE" && "$FILE" != *".zip" ]]; then | ||
echo "$FILE does not exist." | ||
fi | ||
SIZE=$(wc -c $FILE | awk '{print $1}') | ||
if [[ $SIZE -eq 0 ]]; then | ||
echo "$FILE is empty." | ||
fi | ||
MIME=$(file -b --mime-type $FILE) | ||
upload_asset $FILE $SIZE $MIME | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters