Skip to content

Commit ef521d1

Browse files
author
Travis CI
committed
Releasing v1.1
1 parent 2f0cbf0 commit ef521d1

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

github-cli.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
create_release(){
46
local USERNAME=$1
57
local REPOSITORY=$2
@@ -14,10 +16,9 @@ create_release(){
1416
"prerelease": true
1517
}'
1618
local PAYLOAD=$(printf "$PAYLOAD" $APP_VERSION $APP_VERSION $APP_VERSION "$DESC")
17-
local TAG_ID=$(\
18-
curl -i -s -f -X POST "https://api.github.com/repos/${USERNAME}/${REPOSITORY}/releases?access_token=$REPO_TOKEN" \
19-
--data "$PAYLOAD" | grep -o -E 'id": [0-9]+'| awk '{print $2}' | head -n 1 \
20-
)
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)
2122
echo "> Release created with id $TAG_ID" >&2
2223
echo $TAG_ID
2324
}
@@ -32,9 +33,14 @@ validate_repo_token(){
3233
}
3334

3435
create_tag(){
36+
git config user.email "[email protected]"
37+
git config user.name "Travis CI"
38+
39+
git commit -a -m "Releasing ${APP_VERSION}"
40+
git tag ${APP_VERSION}
41+
3542
REMOTE="https://${REPO_TOKEN}@github.com/${USERNAME}/${REPOSITORY}.git"
36-
git tag ${APP_VERSION} -a -m "Releasing ${APP_VERSION}"
37-
git push "$REMOTE" --tags
43+
git push "$REMOTE" "$CURRENT_BRANCH:$CURRENT_BRANCH" --tags
3844
git status
3945
echo "> Pushed"
4046
}
@@ -43,21 +49,26 @@ create_tag(){
4349
USERNAME=$2
4450
REPOSITORY=$3
4551
APP_VERSION=$4
52+
CURRENT_BRANCH=$5
4653

4754
echo "> USERNAME=${USERNAME}, REPOSITORY=${REPOSITORY}, APP_VERSION=${APP_VERSION}"
4855

4956
case $1 in
5057

5158
release )
5259

53-
5460
validate_repo_token
5561

5662
create_tag
5763

5864
create_release $USERNAME $REPOSITORY $APP_VERSION
5965

6066
;;
67+
68+
create-tag )
69+
create_tag
70+
;;
71+
6172
create-release )
6273
create_release $USERNAME $REPOSITORY $APP_VERSION
6374
;;

0 commit comments

Comments
 (0)