Skip to content

Commit 2f0cbf0

Browse files
committed
initial commit
0 parents  commit 2f0cbf0

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
indent_style = space
12+
indent_size = 2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

github-cli.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
create_release(){
4+
local USERNAME=$1
5+
local REPOSITORY=$2
6+
local APP_VERSION=$3
7+
local DESC=$4
8+
local PAYLOAD='{
9+
"tag_name": "%s",
10+
"target_commitish": "%s",
11+
"name": "%s",
12+
"body": "%s",
13+
"draft": false,
14+
"prerelease": true
15+
}'
16+
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+
)
21+
echo "> Release created with id $TAG_ID" >&2
22+
echo $TAG_ID
23+
}
24+
25+
upload_file(){
26+
curl --data-binary "@$SOURCE_FILE" -i -w '\n' -f -s -X POST -H 'Content-Type: application/octet-stream' \
27+
"https://uploads.github.com/repos/$REPO_URL/releases/$TAG_ID/assets?name=$TARGET_FILE&access_token=$REPO_TOKEN"
28+
}
29+
30+
validate_repo_token(){
31+
if [ "$REPO_TOKEN" = "" ] ; then echo "REPO_TOKEN cannot be empty"; exit 1; fi
32+
}
33+
34+
create_tag(){
35+
REMOTE="https://${REPO_TOKEN}@github.com/${USERNAME}/${REPOSITORY}.git"
36+
git tag ${APP_VERSION} -a -m "Releasing ${APP_VERSION}"
37+
git push "$REMOTE" --tags
38+
git status
39+
echo "> Pushed"
40+
}
41+
42+
# REPO_TOKEN=$2
43+
USERNAME=$2
44+
REPOSITORY=$3
45+
APP_VERSION=$4
46+
47+
echo "> USERNAME=${USERNAME}, REPOSITORY=${REPOSITORY}, APP_VERSION=${APP_VERSION}"
48+
49+
case $1 in
50+
51+
release )
52+
53+
54+
validate_repo_token
55+
56+
create_tag
57+
58+
create_release $USERNAME $REPOSITORY $APP_VERSION
59+
60+
;;
61+
create-release )
62+
create_release $USERNAME $REPOSITORY $APP_VERSION
63+
;;
64+
65+
esac

0 commit comments

Comments
 (0)