Skip to content

Commit 5e7c6f5

Browse files
committed
ci: fix not release bug in android build
1 parent dc40a1d commit 5e7c6f5

2 files changed

Lines changed: 101 additions & 4 deletions

File tree

.github/workflows/android_build.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name: Android Build ## name of the workflow
33
on:
44
push:
55
branches:
6-
- main
6+
- dev
7+
8+
permissions:
9+
contents: write
710

811
jobs:
912
android-build:
@@ -60,11 +63,17 @@ jobs:
6063
git config --local user.name "xianshenglu"
6164
npm run changelog
6265
git push --follow-tags
63-
64-
- name: Release
66+
67+
- name: 'Get Previous tag'
68+
id: previous_tag
69+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
70+
with:
71+
fallback: 1.0.0
72+
73+
- name: Release
6574
uses: softprops/action-gh-release@v1
66-
if: startsWith(github.ref, 'refs/tags/')
6775
with:
76+
tag_name: ${{steps.previous_tag.outputs.tag}}
6877
files: ${{steps.sign_app.outputs.signedReleaseFile}}
6978

7079

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Android Build ## name of the workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
android-build:
13+
name: Android Build
14+
runs-on: ubuntu-latest # using ubuntu latest version / or you can use a specific version
15+
16+
steps:
17+
- name: Check out Git repository # clone the repo to local ci workspace
18+
uses: actions/checkout@v2
19+
20+
- name: Set up our JDK environment # setup JDK environment: mandatory as we need to build android project
21+
uses: actions/setup-java@v1.4.3
22+
with:
23+
java-version: 1.8
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
# configure cash for gradle : will help to reduce build time
29+
- name: Cache Gradle Wrapper
30+
uses: actions/cache@v2
31+
with:
32+
path: ~/.gradle/wrapper
33+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
34+
35+
- name: Cache Gradle Dependencies
36+
uses: actions/cache@v2
37+
with:
38+
path: ~/.gradle/caches
39+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
40+
restore-keys: |
41+
${{ runner.os }}-gradle-caches-
42+
- name: Make Gradlew Executable
43+
run: cd android && chmod +x ./gradlew
44+
45+
- name: Generate App APK
46+
run: |
47+
cd android && ./gradlew assembleRelease --no-daemon
48+
49+
## sign generated apk
50+
- name: Sign APK
51+
id: sign_app
52+
uses: r0adkll/sign-android-release@v1
53+
with:
54+
releaseDirectory: android/app/build/outputs/apk/release
55+
signingKeyBase64: ${{ secrets.MYAPP_UPLOAD_STORE_FILE_BASE64 }}
56+
alias: ${{ secrets.MYAPP_UPLOAD_KEY_ALIAS }}
57+
keyStorePassword: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }}
58+
keyPassword: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }}
59+
60+
- name: Changelog
61+
run: |
62+
git config --local user.email "xianshenglu@qq.com"
63+
git config --local user.name "xianshenglu"
64+
npm run changelog
65+
git push --follow-tags
66+
67+
- name: 'Get Previous tag'
68+
id: previous_tag
69+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
70+
with:
71+
fallback: 1.0.0
72+
73+
- name: Release
74+
uses: softprops/action-gh-release@v1
75+
with:
76+
tag_name: ${{steps.previous_tag.outputs.tag}}
77+
files: ${{steps.sign_app.outputs.signedReleaseFile}}
78+
79+
80+
81+
## Distribute app to Firebase App Distribution for testing / use google play internal track if you have a google play account
82+
# - name: upload artifact to Firebase App Distribution
83+
# uses: wzieba/Firebase-Distribution-Github-Action@v1
84+
# with:
85+
# appId: ${{secrets.ANDROID_FIREBASE_APP_ID}}
86+
# token: ${{secrets.ANDROID_FIREBASE_TOKEN}}
87+
# groups: testers
88+
# file: ${{steps.sign_app.outputs.signedReleaseFile}}

0 commit comments

Comments
 (0)