forked from anitab-org/mentorship-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-apks.sh
52 lines (42 loc) · 1.57 KB
/
generate-apks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
if [ "$TRAVIS_REPO_SLUG" != "anitab-org/mentorship-flutter" ]; then
echo "Not the original repo. Skip apk upload."
exit 0
fi
# Travis build triggered by a PR
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Just a PR. Skip apk upload."
exit 0
fi
# Travis build triggered by commit to a branch other than develop
if [ "$TRAVIS_BRANCH" != "develop" ]; then
echo "Not pushed to develop branch. Skip apk upload."
exit 0
fi
# Get the name of the author from the last commit
COMMITTER_NAME=$(git log -1 --pretty=format:'%an')
# Pushing generated apks to apk branch
if [ "$TRAVIS_BRANCH" == "develop" ]; then
echo "Pushed to develop branch. Uploading apk(s) to apk branch."
# Setting up git configurations
git config --global user.name "Techno-Disaster"
git config --global user.email "[email protected]"
# Creating a new git repository
cd $HOME
mkdir apk
cd apk
git init
# Copy the generated apks in to the repository we just created
cp $HOME/build/anitab-org/mentorship-flutter/build/app/outputs/apk/release/app-release.apk $HOME/apk/
# Add and commit the apks
git add app-release.apk
git commit -m "Apk update: Travis build $TRAVIS_BUILD_NUMBER by $COMMITTER_NAME"
# Rename the current branch from master to apk
git branch -m apk
# Pushing the apk branch to the anitab-org repository
git push https://anitab-org:[email protected]/anitab-org/mentorship-flutter apk -fq> /dev/null
if [ $? -eq 0 ]; then
echo "Apk push successful."
else
echo "Apk push failed."
fi
fi