-
-
Notifications
You must be signed in to change notification settings - Fork 147
130 lines (109 loc) · 3.78 KB
/
ios.yml
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
name: Build for iOS
# Using instructions from
# https://docs.flutter.dev/deployment/ios#create-a-build-archive-with-codemagic-cli-tools
on:
# Enable manual run
workflow_dispatch:
push:
tags:
- '**'
env:
project-id: com.adilhanney.saber
jobs:
get-version:
name: Get version
runs-on: ubuntu-latest
outputs:
buildName: ${{ steps.get_version.outputs.buildName }}
buildNumber: ${{ steps.get_version.outputs.buildNumber }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: get_version
run: |
# get buildName from lib/data/version.dart
buildName=$(grep -oP "(?<=buildName = ').*(?=')" lib/data/version.dart)
echo "buildName=$buildName" >> $GITHUB_OUTPUT
# get buildNumber from lib/data/version.dart
buildNumber=$(grep -oP '(?<=buildNumber = ).*(?=;)' lib/data/version.dart)
echo "buildNumber=$buildNumber" >> $GITHUB_OUTPUT
build-ios:
name: Build for iOS
runs-on: macos-latest
needs: get-version
env:
APP_STORE_CONNECT_ISSUER_ID: ${{secrets.APP_STORE_CONNECT_ISSUER_ID}}
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{secrets.APP_STORE_CONNECT_KEY_IDENTIFIER}}
APP_STORE_CONNECT_PRIVATE_KEY: ${{secrets.APP_STORE_CONNECT_PRIVATE_KEY}}
APP_STORE_CERTIFICATE_KEY: ${{secrets.APP_STORE_CERTIFICATE_KEY}}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Remove unneeded files
run: |
rm -rf android
rm -rf appimage
rm -rf assets_raw
rm -rf flatpak
rm -rf installers
rm -rf integration_test
rm -rf linux
rm -rf macos
rm -rf metadata
rm -rf snap
rm -rf submodules
rm -rf test
rm -rf windows
- name: Setup cache
uses: actions/cache@v3
with:
path: |
build
key: ${{ runner.OS }}-saber-${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('**/*.dart') }}
restore-keys: |
${{ runner.OS }}-saber-
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:'
architecture: x64
- name: Install Codemagic CLI Tools
run: pip3 install codemagic-cli-tools
- name: Setup keychain
run: |
keychain initialize
app-store-connect fetch-signing-files $(xcode-project detect-bundle-id) \
--platform IOS \
--type IOS_APP_STORE \
--certificate-key=@env:APP_STORE_CERTIFICATE_KEY \
--create
keychain add-certificates
xcode-project use-profiles
- run: flutter pub get
- run: find . -name "Podfile" -execdir pod install \;
- name: Build for iOS
id: build
run: |
flutter build ipa \
--dart-define=FLAVOR="App Store" \
--dart-define=APP_STORE="App Store" \
--dart-define=UPDATE_CHECK="false" \
--dart-define=DIRTY="false" \
--export-options-plist=$HOME/export_options.plist
export ipaPath="Saber_v${{ needs.get-version.outputs.buildName }}.ipa"
mv $(find $(pwd) -name "*.ipa") $ipaPath
echo "ipaPath=$ipaPath" >> $GITHUB_OUTPUT
- name: Restore keychain
run: |
keychain use-login
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Saber-iOS-Archive
path: ${{ steps.build.outputs.ipaPath }}
- name: Publish to App Store
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: app-store-connect publish --path ${{ steps.build.outputs.ipaPath }}