Skip to content

Commit f8ddeca

Browse files
author
Travis CI
committed
implementing upload
1 parent 2b5fec2 commit f8ddeca

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

github-cli.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,26 @@ create_release(){
2626
echo -e "> Can't create release: \n $(cat /tmp/stderr)"
2727
exit 1
2828
fi
29-
TAG_ID=$(cat /tmp/stdout)
30-
echo "> Release created with id $TAG_ID" >&2
31-
echo $TAG_ID
29+
local RELEASE_ID=$(cat /tmp/stdout)
30+
echo "> Release created with id $RELEASE_ID" >&2
31+
echo $RELEASE_ID
3232
}
3333

3434
upload_file(){
35-
curl --data-binary "@$SOURCE_FILE" -i -w '\n' -f -s -X POST -H 'Content-Type: application/octet-stream' \
36-
"https://uploads.github.com/repos/$REPO_URL/releases/$TAG_ID/assets?name=$TARGET_FILE&access_token=$REPO_TOKEN"
35+
curl --data-binary "@$SOURCE_FILE" -i -w '\n' -s -X POST \
36+
-H 'Content-Type: application/octet-stream' \
37+
"https://uploads.github.com/repos/${USERNAME}/${REPOSITORY}/releases/$RELEASE_ID/assets?name=$TARGET_FILE&access_token=$REPO_TOKEN"
38+
}
39+
40+
upload_files(){
41+
for SOURCE_FILE in "$@"; do
42+
if [ -f $SOURCE_FILE ]; then
43+
TARGET_FILE="$(basename $SOURCE_FILE)"
44+
echo "> uploading $TARGET_FILE"
45+
md5sum $SOURCE_FILE && ls -lha $SOURCE_FILE
46+
upload_file
47+
fi
48+
done
3749
}
3850

3951
validate_repo_token(){
@@ -53,7 +65,6 @@ create_tag(){
5365
echo "> Pushed"
5466
}
5567

56-
# REPO_TOKEN=$2
5768
USERNAME="$2"
5869
REPOSITORY="$3"
5970
APP_VERSION="$4"
@@ -70,7 +81,9 @@ case $1 in
7081

7182
create_tag
7283

73-
create_release $USERNAME $REPOSITORY $APP_VERSION $CURRENT_BRANCH "$DESC"
84+
RELEASE_ID=$(create_release $USERNAME $REPOSITORY $APP_VERSION $CURRENT_BRANCH "$DESC")
85+
86+
upload_files "$@"
7487

7588
;;
7689

@@ -82,4 +95,9 @@ case $1 in
8295
create_release $USERNAME $REPOSITORY $APP_VERSION $CURRENT_BRANCH "$DESC"
8396
;;
8497

98+
upload-files )
99+
RELEASE_ID="$4"
100+
upload_files "$@"
101+
;;
102+
85103
esac

0 commit comments

Comments
 (0)