-
Notifications
You must be signed in to change notification settings - Fork 3
125 lines (98 loc) · 3.78 KB
/
android-dev.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Workflow to build, test and push the dev version whenever a change is made to the develop branch
name: Dev Build
on:
push:
branches: [ develop ]
# Ignore documentation changes
paths-ignore: [ '*.md' ]
jobs:
build:
# Skip commits with "skip ci" in the message, i.e. commits created by GitHub Actions
if: contains(github.event.head_commit.message, 'skip ci') == false
runs-on: ubuntu-latest
steps:
- name: Cancel Queued/In Progress Workflows
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}
- name: Clone Repo
uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
- name: Cache Gems
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gem-
- name: Cache Gradle Dependencies
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Setup Secrets
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }}
PRIVATE_PROPERTIES: ${{ secrets.PRIVATE_PROPERTIES }}
run: |
echo $GOOGLE_SERVICES | base64 -di > app/google-services.json
# Create the .signing folder, add the signing related files
cd ..
mkdir .signing
cd .signing
echo "$PRIVATE_PROPERTIES" | base64 -di > private.properties
# Create the user-level gradle.properties
mkdir -p ~/.gradle/
echo "GRADLE_USER_HOME=$HOME/.gradle" >> $GITHUB_ENV
cd ~/.gradle
echo "$GRADLE_PROPERTIES" | base64 -di > ./gradle.properties
- name: Install Gems
run: |
bundle config path vendor/bundle
bundle install
- name: Install Firebase
run: sudo npm install -g firebase-tools
- name: Increment Build Number
run: ./gradlew incrementBuildNumber
- name: Assemble Debug
run: ./gradlew clean assembleDebug
- name: Run Unit Tests
run: ./gradlew testDebugUnitTest
- name: Extract Version Number
run: |
# Get the latest build tools
export BUILD_TOOLS=$($ANDROID_HOME/tools/bin/sdkmanager --list | grep "build-tools/" | awk '{ print $3 }' | tail -1)
# Grab the version name from the generated APK
version=$($ANDROID_HOME/build-tools/$BUILD_TOOLS/aapt dump badging app/build/outputs/apk/debug/app-debug.apk | grep versionName | awk '{print $4}' | grep -o [0-9].*[0-9])
echo "VERSION=$version/.gradle" >> $GITHUB_ENV
- name: Assemble Dev APK
run: ./gradlew clean assembleDev
- name: Deploy Dev
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: bundle exec fastlane dev
- name: Commit & Tag Version
run: |
# Set the user info
git config --global user.email "julienguerinet@gmail.com"
git config --global user.name "Julien Guerinet (Auto Commit)"
# Add all files
git add . || exit 1
# Commit
git commit -m"v$VERSION, skip ci" || exit 1
# Tag
git tag "$VERSION"
# Pull
git pull --rebase || exit 1
# Push
git push --force && git push --tags || exit 1