Skip to content

Commit 3f7ea8e

Browse files
author
Travis CI
committed
fixing release creating
1 parent 2c102aa commit 3f7ea8e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

github-cli.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ create_release(){
66
local USERNAME=$1
77
local REPOSITORY=$2
88
local APP_VERSION=$3
9-
local DESC=$4
9+
local CURRENT_BRANCH=$4
10+
local DESC=$5
1011
local PAYLOAD='{
1112
"tag_name": "%s",
1213
"target_commitish": "%s",
@@ -15,10 +16,14 @@ create_release(){
1516
"draft": false,
1617
"prerelease": true
1718
}'
18-
local PAYLOAD=$(printf "$PAYLOAD" $APP_VERSION $APP_VERSION $APP_VERSION "$DESC")
19-
curl -i -s -X POST "https://api.github.com/repos/${USERNAME}/${REPOSITORY}/releases?access_token=$REPO_TOKEN" \
20-
--data "$PAYLOAD"
21-
local TAG_ID=$(echo "" | grep -o -E 'id": [0-9]+'| awk '{print $2}' | head -n 1)
19+
local PAYLOAD=$(printf "$PAYLOAD" $APP_VERSION $CURRENT_BRANCH $APP_VERSION "$DESC")
20+
(curl -s -X POST -w '%{stderr}%{http_code}\n%{stdout}\n' \
21+
"https://api.github.com/repos/${USERNAME}/${REPOSITORY}/releases?access_token=$REPO_TOKEN" \
22+
--data "$PAYLOAD" |\
23+
tee -a /dev/stderr | jq -r '.id') 2> /tmp/stderr 1> /tmp/stdout
24+
25+
test $(cat /tmp/stderr | head -n 1) -eq 200
26+
TAG_ID=$(cat /tmp/stdout)
2227
echo "> Release created with id $TAG_ID" >&2
2328
echo $TAG_ID
2429
}
@@ -50,8 +55,9 @@ USERNAME=$2
5055
REPOSITORY=$3
5156
APP_VERSION=$4
5257
CURRENT_BRANCH=$5
58+
DESC=$6
5359

54-
echo "> USERNAME=${USERNAME}, REPOSITORY=${REPOSITORY}, APP_VERSION=${APP_VERSION}"
60+
echo "> USERNAME=${USERNAME}, REPOSITORY=${REPOSITORY}, APP_VERSION=${APP_VERSION}, CURRENT_BRANCH=${CURRENT_BRANCH}, DESC=${DESC}"
5561

5662
case $1 in
5763

@@ -61,7 +67,7 @@ case $1 in
6167

6268
create_tag
6369

64-
create_release $USERNAME $REPOSITORY $APP_VERSION
70+
create_release $USERNAME $REPOSITORY $APP_VERSION $CURRENT_BRANCH $DESC
6571

6672
;;
6773

@@ -70,7 +76,7 @@ case $1 in
7076
;;
7177

7278
create-release )
73-
create_release $USERNAME $REPOSITORY $APP_VERSION
79+
create_release $USERNAME $REPOSITORY $APP_VERSION $CURRENT_BRANCH $DESC
7480
;;
7581

7682
esac

0 commit comments

Comments
 (0)