-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (202 loc) · 6.79 KB
/
build.yml
File metadata and controls
207 lines (202 loc) · 6.79 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: "Build all flutter archs"
on:
workflow_dispatch:
release:
types: [ created ]
jobs:
do_tests:
name: Flutter Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: |
assets
lib
test
scripts
- uses: subosito/flutter-action@v2
with:
cache: true
- name: Download dependencies
run: flutter pub get
- name: Run tests
run: flutter test
gen_icons:
name: Generate icons & commit/push them
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check latest commit to assets
id: assets
# This job should not run when the latest commit to assets is older than 1 day
# This is to reduce unnecessary running minutes
run: |
COMMITS=$(curl -s "https://api.github.com/repos/${{ github.repository }}/commits?path=assets&page=1&per_page=1")
DAYS=$(echo $COMMITS | jq -r "((now - (.[0].commit.committer.date | fromdateiso8601) ) / (60*60*24) | trunc)")
echo "days=$DAYS" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
if: steps.assets.output.days == 0
with:
ref: main
- uses: subosito/flutter-action@v2
if: steps.assets.output.days == 0
with:
cache: true
- name: Download dependencies
run: flutter pub get
- name: Generate flutter launcher icons
if: steps.assets.output.days == 0
run: flutter pub run flutter_launcher_icons
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v5
if: steps.assets.output.days == 0
with:
commit_message: Generated icon files
file_pattern: '*.xml *.json *.png'
build_web:
name: Build & publish for gh-pages
if: github.event_name == 'release' && always()
runs-on: ubuntu-latest
needs: [ do_tests, gen_icons, build_ios ]
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Setup node for publishing AltStore repo
uses: actions/setup-node@v1
with:
node-version: '10.x'
- uses: subosito/flutter-action@v2
with:
cache: true
- run: flutter pub get
- name: Run altstore-github
run: npx github:randommodderjdk/altstore-github --config web/altstore.template.json > web/altstore.json
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: '~/.npm'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Implement this troguh other action - run: dart run sqflite_common_ffi_web:setup
- name: Deploy
uses: bluefireteam/flutter-gh-pages@v9
with:
compileToWasm: true
baseHref: /${{ github.event.repository.name }}/
build_ios:
name: Build iOS ipa
needs: [ do_tests, gen_icons ]
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: subosito/flutter-action@v2
with:
cache: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 16.4
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
#with:
# sparse-checkout: |
# assets
# lib
# scripts
# ios
- name: Gathering dependencies
run: flutter pub get
- name: Build ios xcarchive
run: flutter build ipa --release --no-codesign
- name: Package xcarchive to ipa
run: |
brew install ldid
chmod +x ${PWD}/scripts/package_ipa.sh
${PWD}/scripts/package_ipa.sh ${PWD}/build/ios/archive/Runner.xcarchive .
- name: Get current date
id: date
run: echo "date={$(date +'%Y-%m-%d')}" >> $GITHUB_ENV
- name: Push artifact
uses: actions/upload-artifact@v4
with:
name: HW-manager-${{ env.date }}.ipa
path: ./hw_manager_flutter.ipa
- name: Upload files to a GitHub release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: hw-manager-${{ github.ref_name }}.ipa
file: ./hw_manager_flutter.ipa
tag: ${{ github.ref }}
build_android:
name: Build APK split by arch
needs: [ do_tests, gen_icons ]
runs-on: macos-latest
permissions:
contents: write
steps:
- name: 'Set up JDK 17'
uses: 'actions/setup-java@v1'
with:
java-version: '17'
distribution: 'temurin'
- uses: gradle/actions/setup-gradle@v4
id: setup-gradle
with:
gradle-version: '8.14.3'
# Set up JDK 17 using the "actions/setup-java" action.
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: 'cmake;3.22.1 ndk;27.0.12077973 build-tools;30.0.3 platforms;android-31 platforms;android-32 platforms;android-33'
- uses: subosito/flutter-action@v2
with:
cache: true
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
#with:
# sparse-checkout: |
# assets
# lib
# scripts
# ios
- name: Gathering dependencies
run: flutter pub get
- name: Decode Keystore
run: |
echo "${{ secrets.JKS_B64 }}" | base64 --decode > android/app/keystore.jks
- name: Create key.properties
run: |
echo "storePassword=${{ secrets.JKS_PW }}" > android/key.properties
echo "keyPassword=${{ secrets.KEY_PW }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
echo "storeFile=keystore.jks" >> android/key.properties
- name: Build apk
id: 'apkbuild'
run: 'flutter doctor -v; flutter build apk --split-per-abi --verbose && ls build/app/outputs/flutter-apk && echo "apkbuild=build/app/outputs/flutter-apk/" >> $GITHUB_ENV'
- name: Get current date
id: date
run: echo "date={$(date +'%Y-%m-%d')}" >> $GITHUB_ENV
- name: Push artifact
uses: actions/upload-artifact@v4
with:
name: HW-manager-${{ env.date }}
path: build/app/outputs/flutter-apk/
- name: Upload files to a GitHub release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: build/app/outputs/flutter-apk/*
tag: ${{ github.ref }}