Skip to content

Commit d27784a

Browse files
committed
release workflow
1 parent d7ed878 commit d27784a

File tree

5 files changed

+503
-3
lines changed

5 files changed

+503
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ dmypy.json
128128
.pyre/
129129

130130
# buildozer
131-
.buildozer/**/platform/build*/**
131+
.buildozer
132132

133133
*.profile
134134
*.dat

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ debug:
99
release:
1010
buildozer -v android release
1111

12-
publish: release debug
12+
publish: release
1313
$(shell ./publish.sh)
1414

1515
adb-run-debug: debug

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33

4-
__version__ = "1.0.1"
4+
__version__ = "1.0.2b"
55

66

77
def main():

publish.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
GH_REPO_USER=sarumaj
4+
GH_REPO=MyCampusMobile
5+
GH_USER=sarumaj
6+
GH_TOKEN=$(git config --global --list | grep url | sed -E 's|.*:(.*)@.*|\1|g')
7+
GH_TARGET=main
8+
ASSETS_PATH=bin
9+
VERSION=$(cat main.py | grep '__version__ = ' | sed -rE 's|.*"([0-9]+\.[0-9]+\.[0-9]+\w?)".*|\1|g')
10+
11+
if [[ ! -z $(git tag --list $VERSION) ]]
12+
then
13+
git add -u
14+
git commit -m "$VERSION release" --no-verify
15+
git tag "v${VERSION}"
16+
git push --follow-tags
17+
git push origin "v${VERSION}"
18+
fi
19+
20+
rel_id=$(
21+
curl \
22+
--silent --user "$GH_USER:$GH_TOKEN" \
23+
-X GET https://api.github.com/repos/${GH_REPO_USER}/${GH_REPO}/releases/tags/v${VERSION} \
24+
| jq -r '.id'
25+
)
26+
echo Found release ${rel_id}
27+
28+
if [[ $rel_id -eq null ]]
29+
then
30+
echo Creating release
31+
response=$(
32+
curl \
33+
--silent --user "$GH_USER:$GH_TOKEN" \
34+
-X POST https://api.github.com/repos/${GH_REPO_USER}/${GH_REPO}/releases \
35+
--data '{
36+
"tag_name": "v'$VERSION'",
37+
"target_commitish": "'$GH_TARGET'",
38+
"name": "v'$VERSION'",
39+
"body": "version release: '$VERSION'",
40+
"draft": false,
41+
"prerelease": false
42+
}')
43+
rel_id=$( jq -r '.id' <<<$response)
44+
else
45+
echo Updating release ${release_id}
46+
response=$(
47+
curl \
48+
--silent --user "$GH_USER:$GH_TOKEN" \
49+
-X PATCH https://api.github.com/repos/${GH_REPO_USER}/${GH_REPO}/releases/$rel_id \
50+
--data '{
51+
"tag_name": "v'$VERSION'",
52+
"target_commitish": "'$GH_TARGET'",
53+
"name": "v'$VERSION'",
54+
"body": "version release: '$VERSION'",
55+
"draft": false,
56+
"prerelease": false
57+
}')
58+
fi
59+
echo Result: ${response}
60+
61+
62+
for i in $ASSETS_PATH/* ; do
63+
file_name=$(basename $i)
64+
echo uploading ${file_name}
65+
curl \
66+
--user "$GH_USER:$GH_TOKEN" \
67+
-X POST https://uploads.github.com/repos/${GH_REPO_USER}/${GH_REPO}/releases/${rel_id}/assets?name=${file_name} \
68+
--header 'Content-Type: application/octet-stream' \
69+
--upload-file "./${ASSETS_PATH}/${file_name}" 2>&1 >/dev/null
70+
done

0 commit comments

Comments
 (0)