Skip to content

Commit e762f82

Browse files
authored
chore: updated ga scripts to upload apks (#2314)
1 parent acb5301 commit e762f82

File tree

2 files changed

+109
-38
lines changed

2 files changed

+109
-38
lines changed

.github/workflows/pull-request.yml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
name: Build
22

33
on:
4-
push:
5-
branches:
6-
- master
74
pull_request:
85
branches:
96
- master
107
- development
118

129
jobs:
1310
build:
14-
1511
runs-on: ubuntu-latest
1612

1713
steps:
@@ -27,37 +23,3 @@ jobs:
2723
- name: Build with Gradle
2824
run: |
2925
bash ./gradlew build --stacktrace
30-
bash ./gradlew bundle --stacktrace
31-
32-
- name: Upload APK
33-
uses: actions/upload-artifact@v2
34-
with:
35-
name: pslab-android-apk
36-
path: |
37-
app/build/outputs/apk/debug/app-debug.apk
38-
app/build/outputs/apk/release/app-release-unsigned.apk
39-
40-
- name: Download Artifact
41-
uses: actions/download-artifact@v2
42-
with:
43-
name: pslab-android-apk
44-
45-
- name: Add APK files to apk branch
46-
if: github.ref=='refs/heads/master'
47-
run: |
48-
git config user.name github-actions
49-
git config user.email github-actions@github.com
50-
git stash
51-
git switch --orphan temp
52-
git push origin --delete apk
53-
git branch -m apk
54-
git config user.name github-actions
55-
git config user.email github-actions@github.com
56-
git add app/build/outputs/bundle/debug/app-debug.aab
57-
git add app/build/outputs/bundle/release/app-release.aab
58-
git add debug/app-debug.apk
59-
git add release/app-release-unsigned.apk
60-
git commit -m "Updated Build"
61-
git push origin apk --force
62-
63-

.github/workflows/push-event.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Push
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- development
8+
9+
env:
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
branch: ${{ steps.branch-name.outputs.current_branch }}
17+
18+
steps:
19+
- name: Download repository
20+
uses: actions/checkout@v2
21+
22+
- name: Setup Java
23+
uses: actions/setup-java@v2
24+
with:
25+
distribution: 'adopt'
26+
java-version: '11'
27+
28+
- name: Build with Gradle
29+
run: |
30+
bash ./gradlew build --stacktrace
31+
bash ./gradlew bundle --stacktrace
32+
33+
- name: Store APK files
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: apk-files
37+
path: |
38+
app/build/outputs/apk/debug/app-debug.apk
39+
app/build/outputs/apk/release/app-release-unsigned.apk
40+
app/build/outputs/bundle/debug/app-debug.aab
41+
app/build/outputs/bundle/release/app-release.aab
42+
43+
- name: Define branch
44+
id: branch-name
45+
run: echo "::set-output name=current_branch::${{ github.ref_name }}"
46+
47+
upload:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Clone APK branch
53+
uses: actions/checkout@v2
54+
with:
55+
repository: fossasia/pslab-android
56+
ref: apk
57+
58+
- name: Clean APK branch for master builds
59+
if: ${{ needs.build.outputs.branch == 'master' }}
60+
run: |
61+
rm -rf app-debug-master.apk || true
62+
rm -rf app-release-unsigned-master.apk || true
63+
rm -rf app-debug-master.aab || true
64+
rm -rf app-release-master.aab || true
65+
66+
- name: Clean APK branch for development builds
67+
if: ${{ needs.build.outputs.branch == 'development' }}
68+
run: |
69+
rm -rf app-debug-development.apk || true
70+
rm -rf app-release-unsigned-development.apk || true
71+
rm -rf app-debug-development.aab || true
72+
rm -rf app-release-development.aab || true
73+
74+
- name: Retrieve APK files
75+
uses: actions/download-artifact@v2
76+
with:
77+
name: apk-files
78+
79+
- name: Rename files in master branch
80+
if: ${{ needs.build.outputs.branch == 'master' }}
81+
run: |
82+
mv apk/debug/app-debug.apk app-debug-master.apk
83+
mv apk/release/app-release-unsigned.apk app-release-unsigned-master.apk
84+
mv bundle/debug/app-debug.aab app-debug-master.aab
85+
mv bundle/release/app-release.aab app-release-master.aab
86+
87+
- name: Rename files in development branch
88+
if: ${{ needs.build.outputs.branch == 'development' }}
89+
run: |
90+
mv apk/debug/app-debug.apk app-debug-development.apk
91+
mv apk/release/app-release-unsigned.apk app-release-unsigned-development.apk
92+
mv bundle/debug/app-debug.aab app-debug-development.aab
93+
mv bundle/release/app-release.aab app-release-development.aab
94+
95+
- name: Setup credentials
96+
run: |
97+
git config user.name 'github-actions[bot]'
98+
git config user.email 'github-actions[bot]@users.noreply.github.com'
99+
100+
- name: Update APK branch
101+
run: |
102+
git remote set-url --push origin https://github-actions[bot]:$GITHUB_TOKEN@github.com/${GITHUB_REPOSITORY}
103+
git checkout --orphan temporary
104+
git add .
105+
git commit -m "release: build files from ${{ needs.build.outputs.branch }} branch"
106+
git branch -D apk
107+
git branch -m apk
108+
git push origin apk -f --quiet > /dev/null
109+

0 commit comments

Comments
 (0)