-
Notifications
You must be signed in to change notification settings - Fork 818
130 lines (110 loc) · 4.04 KB
/
push-event.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
125
126
127
128
129
name: Push
on:
push:
branches:
- master
- development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch-name.outputs.current_branch }}
steps:
- name: Download repository
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
- name: Prepare Build Keys
if: ${{ github.event_name != 'pull_request' && github.repository == 'fossasia/pslab-android' }}
env:
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
run: |
bash scripts/prep-key.sh
- name: Build with Gradle
env:
STORE_PASS: ${{ secrets.STORE_PASS }}
ALIAS: ${{ secrets.ALIAS }}
KEY_PASS: ${{ secrets.KEY_PASS }}
run: |
bash ./gradlew build --stacktrace
bash ./gradlew bundle --stacktrace
- name: Store APK files
uses: actions/upload-artifact@v3
with:
name: apk-files
path: |
app/build/outputs/apk/debug/app-debug.apk
app/build/outputs/apk/release/app-release-unsigned.apk
app/build/outputs/bundle/debug/app-debug.aab
app/build/outputs/bundle/release/app-release.aab
- name: Define branch
id: branch-name
run: echo "::set-output name=current_branch::${{ github.ref_name }}"
upload:
needs: build
runs-on: ubuntu-latest
steps:
- name: Clone APK branch
uses: actions/checkout@v3
with:
repository: fossasia/pslab-android
ref: apk
- name: Clean APK branch for master builds
if: ${{ needs.build.outputs.branch == 'master' }}
run: |
rm -rf app-debug-master.apk || true
rm -rf app-release-unsigned-master.apk || true
rm -rf app-debug-master.aab || true
rm -rf app-release-master.aab || true
- name: Clean APK branch for development builds
if: ${{ needs.build.outputs.branch == 'development' }}
run: |
rm -rf app-debug-development.apk || true
rm -rf app-release-unsigned-development.apk || true
rm -rf app-debug-development.aab || true
rm -rf app-release-development.aab || true
- name: Retrieve APK files
uses: actions/download-artifact@v3
with:
name: apk-files
- name: Rename files in master branch
if: ${{ needs.build.outputs.branch == 'master' }}
run: |
mv apk/debug/app-debug.apk app-debug-master.apk
mv apk/release/app-release-unsigned.apk app-release-unsigned-master.apk
mv bundle/debug/app-debug.aab app-debug-master.aab
mv bundle/release/app-release.aab app-release-master.aab
- name: Rename files in development branch
if: ${{ needs.build.outputs.branch == 'development' }}
run: |
mv apk/debug/app-debug.apk app-debug-development.apk
mv apk/release/app-release-unsigned.apk app-release-unsigned-development.apk
mv bundle/debug/app-debug.aab app-debug-development.aab
mv bundle/release/app-release.aab app-release-development.aab
- name: Setup credentials
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Update APK branch
run: |
git remote set-url --push origin https://github-actions[bot]:[email protected]/${GITHUB_REPOSITORY}
git checkout --orphan temporary
git add .
git commit -m "release: build files from ${{ needs.build.outputs.branch }} branch"
git branch -D apk
git branch -m apk
git push origin apk -f --quiet > /dev/null