-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (59 loc) · 2.31 KB
/
Copy pathandroid_build.yml
File metadata and controls
76 lines (59 loc) · 2.31 KB
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
name: Build and Deploy Android
on:
push:
branches:
- master
jobs:
build:
if: "!startsWith(github.event.head_commit.message, '[Website]')"
runs-on: ubuntu-latest
steps:
- name: Checkout master branch
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Install dependencies
run: flutter pub get
- name: Run Code Generation
run: dart run build_runner build --delete-conflicting-outputs
- name: Build APK (Release)
run: flutter build apk --release
- name: Build AppBundle (Store)
run: flutter build appbundle --release
- name: Push Build Artifacts to android branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Create a temporary folder for artifacts (using a path outside the repo to be safe)
mkdir ../temp_artifacts
cp build/app/outputs/flutter-apk/app-release.apk ../temp_artifacts/off-chat-release.apk
cp build/app/outputs/bundle/release/app-release.aab ../temp_artifacts/off-chat-release.aab
# Discard all local changes (including generated files) to avoid checkout conflicts
git reset --hard
git clean -fd
# Fetch all branches
git fetch origin
# Switch to (or create) the android branch
if git show-ref --verify --quiet refs/remotes/origin/android; then
git checkout -f android --
git reset --hard origin/android
else
git checkout --orphan android
git rm -rf .
fi
# Move artifacts from temp folder to root
mv ../temp_artifacts/* .
# Add and commit
git add off-chat-release.apk off-chat-release.aab
git commit -m "Automated Android Build: $(date)"
# Force push to the android branch
git push -f origin android