Skip to content

Commit 342fd3e

Browse files
committed
Merge branch 'main' into course-table
2 parents ae01942 + 75796bf commit 342fd3e

File tree

6 files changed

+160
-34
lines changed

6 files changed

+160
-34
lines changed

.github/workflows/pr-preview.yaml

Lines changed: 97 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ on:
1212
description: 'Specific commit SHA to build (overrides branch)'
1313
required: false
1414
type: string
15-
skip_upload:
16-
description: 'Build without uploading or bumping build number'
15+
deploy_android:
16+
description: 'Deploy Android to Firebase App Distribution'
17+
required: false
18+
type: boolean
19+
default: true
20+
deploy_ios:
21+
description: 'Deploy iOS to TestFlight'
1722
required: false
1823
type: boolean
1924
default: false
@@ -36,7 +41,6 @@ jobs:
3641
# so this output may be an empty string. This is intentional; all downstream uses of
3742
# needs.prepare.outputs.comment_id are guarded by the same pull_request-only condition.
3843
comment_id: ${{ steps.create.outputs.comment-id }}
39-
skip_upload: ${{ steps.flags.outputs.skip_upload }}
4044
target_ref: ${{ steps.set-ref.outputs.ref }}
4145
steps:
4246
- name: Checkout Actions
@@ -57,18 +61,7 @@ jobs:
5761
with:
5862
ref: ${{ steps.set-ref.outputs.ref }}
5963

60-
- name: Check for skip-upload flag
61-
id: flags
62-
run: |
63-
COMMIT_MSG="$(git show -s --format=%B)"
64-
if [[ "$COMMIT_MSG" == *"[skip upload]"* ]] || [[ "${{ inputs.skip_upload }}" == "true" ]]; then
65-
echo "skip_upload=true" >> $GITHUB_OUTPUT
66-
else
67-
echo "skip_upload=false" >> $GITHUB_OUTPUT
68-
fi
69-
7064
- name: Manage Build Number
71-
if: steps.flags.outputs.skip_upload != 'true'
7265
id: build-number
7366
uses: ./.github/actions/manage-build-number
7467
with:
@@ -83,17 +76,37 @@ jobs:
8376
build_number: ${{ steps.build-number.outputs.build_number || vars.build_number }}
8477

8578
- name: Find existing comment
86-
if: github.event_name == 'pull_request' && steps.flags.outputs.skip_upload != 'true'
79+
if: github.event_name == 'pull_request'
8780
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
8881
id: find-comment
8982
with:
9083
issue-number: ${{ github.event.pull_request.number }}
9184
comment-author: github-actions[bot]
9285
body-includes: <!-- pr-preview-comment -->
9386

87+
- name: Read existing deploy checkboxes
88+
id: checkboxes
89+
if: github.event_name == 'pull_request'
90+
env:
91+
COMMENT_BODY: ${{ steps.find-comment.outputs.comment-body }}
92+
run: |
93+
ANDROID="x"
94+
IOS=" "
95+
BODY="$COMMENT_BODY"
96+
if [ -n "$BODY" ]; then
97+
if echo "$BODY" | grep -q '<!-- deploy-android -->'; then
98+
[[ "$BODY" =~ \[x\]\ \<\!--\ deploy-android ]] && ANDROID="x" || ANDROID=" "
99+
fi
100+
if echo "$BODY" | grep -q '<!-- deploy-ios -->'; then
101+
[[ "$BODY" =~ \[x\]\ \<\!--\ deploy-ios ]] && IOS="x" || IOS=" "
102+
fi
103+
fi
104+
echo "android=$ANDROID" >> $GITHUB_OUTPUT
105+
echo "ios=$IOS" >> $GITHUB_OUTPUT
106+
94107
- name: Create or update initial comment
95108
id: create
96-
if: github.event_name == 'pull_request' && steps.flags.outputs.skip_upload != 'true'
109+
if: github.event_name == 'pull_request'
97110
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
98111
with:
99112
comment-id: ${{ steps.find-comment.outputs.comment-id }}
@@ -104,6 +117,10 @@ jobs:
104117
**Build Number:** ${{ steps.build-number.outputs.build_number }}
105118
**Commit:** ${{ steps.summary.outputs.sha }}
106119
**Message:** ${{ steps.summary.outputs.message }}
120+
121+
### Deploy
122+
- [${{ steps.checkboxes.outputs.android }}] <!-- deploy-android --> Android (Firebase App Distribution)
123+
- [${{ steps.checkboxes.outputs.ios }}] <!-- deploy-ios --> iOS (TestFlight)
107124
edit-mode: replace
108125

109126
android:
@@ -131,22 +148,51 @@ jobs:
131148
with:
132149
platform: android
133150

151+
- name: Find preview comment
152+
if: github.event_name == 'pull_request'
153+
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
154+
id: find-comment
155+
with:
156+
issue-number: ${{ github.event.pull_request.number }}
157+
comment-author: github-actions[bot]
158+
body-includes: <!-- pr-preview-comment -->
159+
160+
- name: Check deploy checkbox
161+
id: check-deploy
162+
env:
163+
COMMENT_BODY: ${{ steps.find-comment.outputs.comment-body }}
164+
run: |
165+
BODY="$COMMENT_BODY"
166+
if [ -z "$BODY" ]; then
167+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.deploy_android }}" != "false" ]; then
168+
echo "skip_upload=false" >> $GITHUB_OUTPUT
169+
else
170+
echo "skip_upload=true" >> $GITHUB_OUTPUT
171+
fi
172+
exit 0
173+
fi
174+
if echo "$BODY" | grep -q '\[x\] <!-- deploy-android -->'; then
175+
echo "skip_upload=false" >> $GITHUB_OUTPUT
176+
else
177+
echo "skip_upload=true" >> $GITHUB_OUTPUT
178+
fi
179+
134180
- name: Build and upload to Firebase App Distribution
135181
id: upload
136182
env:
137183
FIREBASEAPPDISTRO_APP: ${{ secrets.FIREBASEAPPDISTRO_APP }}
138-
run: bundle exec fastlane android preview skip_upload:${{ needs.prepare.outputs.skip_upload }}
184+
run: bundle exec fastlane android preview skip_upload:${{ steps.check-deploy.outputs.skip_upload }}
139185

140186
- name: Write Android Job Summary
141-
if: needs.prepare.outputs.skip_upload != 'true'
187+
if: steps.check-deploy.outputs.skip_upload != 'true'
142188
uses: ./.github/actions/android-summary
143189
with:
144190
build_number: ${{ needs.prepare.outputs.build_number }}
145191
type: 'firebase'
146192
testing_uri: ${{ steps.upload.outputs.testing_uri }}
147193

148194
- name: Update comment with Android build
149-
if: github.event_name == 'pull_request' && needs.prepare.outputs.skip_upload != 'true'
195+
if: github.event_name == 'pull_request' && steps.check-deploy.outputs.skip_upload != 'true'
150196
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
151197
with:
152198
comment-id: ${{ needs.prepare.outputs.comment_id }}
@@ -190,17 +236,46 @@ jobs:
190236
cd ios && bundle exec pod install
191237
git diff --exit-code Podfile.lock
192238
239+
- name: Find preview comment
240+
if: github.event_name == 'pull_request'
241+
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
242+
id: find-comment
243+
with:
244+
issue-number: ${{ github.event.pull_request.number }}
245+
comment-author: github-actions[bot]
246+
body-includes: <!-- pr-preview-comment -->
247+
248+
- name: Check deploy checkbox
249+
id: check-deploy
250+
env:
251+
COMMENT_BODY: ${{ steps.find-comment.outputs.comment-body }}
252+
run: |
253+
BODY="$COMMENT_BODY"
254+
if [ -z "$BODY" ]; then
255+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.deploy_ios }}" != "false" ]; then
256+
echo "skip_upload=false" >> $GITHUB_OUTPUT
257+
else
258+
echo "skip_upload=true" >> $GITHUB_OUTPUT
259+
fi
260+
exit 0
261+
fi
262+
if echo "$BODY" | grep -q '\[x\] <!-- deploy-ios -->'; then
263+
echo "skip_upload=false" >> $GITHUB_OUTPUT
264+
else
265+
echo "skip_upload=true" >> $GITHUB_OUTPUT
266+
fi
267+
193268
- name: Build and Upload to TestFlight
194-
run: bundle exec fastlane ios beta skip_upload:${{ needs.prepare.outputs.skip_upload }}
269+
run: bundle exec fastlane ios beta skip_upload:${{ steps.check-deploy.outputs.skip_upload }}
195270

196271
- name: Write iOS Job Summary
197-
if: needs.prepare.outputs.skip_upload != 'true'
272+
if: steps.check-deploy.outputs.skip_upload != 'true'
198273
uses: ./.github/actions/ios-summary
199274
with:
200275
build_number: ${{ needs.prepare.outputs.build_number }}
201276

202277
- name: Update comment with iOS build
203-
if: github.event_name == 'pull_request' && needs.prepare.outputs.skip_upload != 'true'
278+
if: github.event_name == 'pull_request' && steps.check-deploy.outputs.skip_upload != 'true'
204279
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
205280
with:
206281
comment-id: ${{ needs.prepare.outputs.comment_id }}

.github/workflows/release-preview.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
platform: ios
124124

125125
- name: Build and Upload to TestFlight (App Store Connect)
126-
run: bundle exec fastlane ios beta release_mode:true
126+
run: bundle exec fastlane ios beta
127127

128128
- name: Write iOS Job Summary
129129
uses: ./.github/actions/ios-summary

doc/Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,11 @@ RUN --mount=type=cache,target=/mise/cache \
2323
mise trust && \
2424
mise install flutter
2525

26-
# Resolve app dependencies
27-
COPY pubspec.* ./
28-
RUN --mount=type=cache,target=/root/.pub-cache \
29-
flutter --disable-analytics && \
30-
flutter pub get --enforce-lockfile
31-
32-
# Copy app source code
26+
# Resolve app dependencies and generate documentation
3327
COPY . .
34-
35-
# Generate documentation
3628
RUN --mount=type=cache,target=/root/.pub-cache \
29+
flutter --disable-analytics && \
30+
flutter pub get --enforce-lockfile && \
3731
dart doc
3832

3933
FROM caddy:2-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d

fastlane/Fastfile

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@ def changelog(pr_number, pr_title, commit_sha, commit_message)
1919
end
2020

2121
platform :ios do
22+
desc "Build, install on connected device, and upload dSYMs"
23+
lane :device do
24+
sync_code_signing(type: "adhoc")
25+
26+
update_code_signing_settings(
27+
path: "ios/Runner.xcodeproj",
28+
sdk: "iphoneos*",
29+
code_sign_identity: "iPhone Distribution",
30+
profile_name: "match AdHoc #{ENV["FASTLANE_APP_IDENTIFIER"]}",
31+
)
32+
33+
archive_path = flutter_build(
34+
build: "ipa",
35+
build_args: ["--no-codesign", "--dart-define=USE_FIREBASE=true"],
36+
)
37+
38+
build_app(
39+
skip_build_archive: true,
40+
archive_path: archive_path,
41+
export_team_id: ENV["FASTLANE_TEAM_ID"],
42+
export_method: "ad-hoc",
43+
suppress_xcode_output: true,
44+
)
45+
46+
install_on_device(ipa: lane_context[SharedValues::IPA_OUTPUT_PATH])
47+
48+
Dir.chdir("..") { sh("dart", "run", "tool/credentials.dart", "fetch") }
49+
50+
upload_symbols_to_crashlytics(
51+
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH],
52+
gsp_path: "ios/Runner/GoogleService-Info.plist",
53+
binary_path: "ios/Pods/FirebaseCrashlytics/upload-symbols",
54+
)
55+
end
56+
2257
desc "Build and upload to TestFlight"
2358
lane :beta do |options|
2459
build_number = options[:build_number] || ENV["BUILD_NUMBER"] || 1
@@ -27,7 +62,6 @@ platform :ios do
2762
commit_sha = options[:commit_sha] || ENV["COMMIT_SHA"] || "manual build"
2863
commit_message = options[:commit_message] || ENV["COMMIT_MESSAGE"] || "This is a manual build without PR information"
2964
skip_upload = options[:skip_upload].to_s == "true"
30-
release_mode = options[:release_mode].to_s == "true"
3165

3266
setup_ci if is_ci
3367

@@ -47,7 +81,7 @@ platform :ios do
4781
archive_path = flutter_build(
4882
build: "ipa",
4983
build_number: build_number,
50-
build_args: ["--no-codesign", "--dart-define=USE_FIREBASE=#{release_mode ? 'true' : 'false'}"],
84+
build_args: ["--no-codesign", "--dart-define=USE_FIREBASE=true"],
5185
)
5286

5387
build_app(
@@ -59,6 +93,14 @@ platform :ios do
5993

6094
next if skip_upload
6195

96+
Dir.chdir("..") { sh("dart", "run", "tool/credentials.dart", "fetch") }
97+
98+
upload_symbols_to_crashlytics(
99+
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH],
100+
gsp_path: "ios/Runner/GoogleService-Info.plist",
101+
binary_path: "ios/Pods/FirebaseCrashlytics/upload-symbols",
102+
)
103+
62104
app_store_connect_api_key(
63105
is_key_content_base64: true,
64106
)
@@ -87,6 +129,7 @@ platform :android do
87129
output_file = flutter_build(
88130
build: "appbundle",
89131
build_number: build_number,
132+
build_args: ["--dart-define=USE_FIREBASE=true"],
90133
)
91134

92135
next if skip_upload

fastlane/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do
1515

1616
## iOS
1717

18+
### ios device
19+
20+
```sh
21+
[bundle exec] fastlane ios device
22+
```
23+
24+
Build, install on connected device, and upload dSYMs
25+
1826
### ios beta
1927

2028
```sh

lib/screens/main/profile/profile_screen.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ class ProfileScreen extends ConsumerWidget {
146146
),
147147

148148
SectionHeader(title: 'TAT'),
149+
// TODO: remove before release
150+
OptionEntryTile(
151+
icon: Icons.rice_bowl_outlined,
152+
title: '點一碗炒飯',
153+
onTap: () => throw Exception('炒飯'),
154+
),
149155
OptionEntryTile(
150156
icon: Icons.favorite_border_outlined,
151157
title: t.profile.options.supportUs,

0 commit comments

Comments
 (0)