-
Notifications
You must be signed in to change notification settings - Fork 11
233 lines (207 loc) · 8.25 KB
/
release.yaml
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Deploy
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
on:
push:
branches:
- main
- develop
- chore/env # TODO(YumNumm): デバッグ用なので後で消す
workflow_dispatch:
inputs:
ios:
description: "Build iOS app"
required: false
default: true
type: boolean
android:
description: "Build Android app"
required: false
default: true
type: boolean
jobs:
define-matrix:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
deploy-ios: ${{ steps.define-environment-matrix.outputs.deploy-ios }}
deploy-android: ${{ steps.define-environment-matrix.outputs.deploy-android }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Decide which app to deploy
id: define-environment-matrix
run: |
platforms=()
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ "${{ inputs.ios }}" = "true" ]; then
platforms+=("ios")
fi
if [ "${{ inputs.android }}" = "true" ]; then
platforms+=("android")
fi
elif [ "${{ github.event_name }}" = "push" ]; then
# コミットメッセージに [release only $platform] を含む場合は、
# そのプラットフォームのみデプロイする
if [[ github.event.head_commit.message =~ \[release[[:space:]]+only[[:space:]]+([a-z,[:space:]]+)\] ]]; then
# [release only platform1,platform2] の形式からプラットフォームを抽出
IFS=',' read -ra selected_platforms <<< "${BASH_REMATCH[1]}"
# 空白を削除して配列に追加
for platform in "${selected_platforms[@]}"; do
platform=$(echo "$platform" | tr -d '[:space:]')
if [[ " ios android" =~ " $platform " ]]; then
platforms+=("$platform")
fi
echo "platform: $platform"
done
else
# [release only] タグがない場合は全プラットフォームをデプロイ
echo "commit message does not contain [release only platform], deploy all platforms"
platforms+=("ios" "android")
fi
else
echo "Unknown event name: ${{ github.event_name }}"
exit 1
fi
echo "デプロイするプラットフォーム: ${platforms[@]}"
for platform in "${platforms[@]}"; do
echo "deploy-${platform}=true" >> $GITHUB_OUTPUT
done
build-ios:
needs: define-matrix
if: ${{ needs.define-matrix.outputs.deploy-ios }}
runs-on: macos-latest
timeout-minutes: 15
steps:
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup application runtime & Resolve dependencies
uses: ./.github/actions/setup-application-runtime
- name: Setup macOS Environment
uses: ./.github/actions/setup-macos-environment
- name: Create App Store Connect API Token
uses: ./.github/actions/generate-app-store-connect-jwt
with:
app_store_connect_api_key_id: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
app_store_connect_api_key_base64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
- name: Fetch latest build number
id: fetch-latest-build-number
run: |
platform=IOS
app_id=6447546703
build_number=$(
curl -s https://api.appstoreconnect.apple.com/v1/builds \
-G \
-d "filter[platform]=${platform}" \
-d "filter[id]=${app_id}" \
-d "sort=-version" \
-d "fields[builds]=version" \
-d "limit=1" | \
jq -r '.data | if length == 0 then 0 else .[0].attributes.version end'
)
build_number=$((build_number + 1))
echo "build_number=${build_number}" >> $GITHUB_OUTPUT
echo "Build Number set to ${build_number}."
- name: Extract Dotenv
run: |
echo "${{ secrets.DOTENV }}" | base64 -d > environment.tar.gz
tar -xzf environment.tar.gz
rm environment.tar.gz
- name: Build iOS
working-directory: app
env:
BUILD_NUMBER: ${{ steps.fetch-latest-build-number.outputs.build_number }}
run: |
echo "BUILD_NUMBER=${BUILD_NUMBER}"
flutter build ipa --no-codesign --build-number=${BUILD_NUMBER} --dart-define-from-file=environment/.env.prod
- name: Extract App Store Connect API Key
working-directory: app/ios
run: echo "${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}" | base64 -d > AuthKey.p8
- name: Archive
working-directory: app
run: |
xcodebuild -workspace ios/Runner.xcworkspace \
-scheme Runner \
-sdk iphoneos \
-configuration Release archive \
-archivePath build/ios/Runner.xcarchive \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO | xcbeautify
xcodebuild -exportArchive \
-archivePath build/ios/Runner.xcarchive \
-exportOptionsPlist ios/ExportOptions.plist \
-exportPath . \
-allowProvisioningUpdates \
-authenticationKeyIssuerID ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} \
-authenticationKeyID ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} \
-authenticationKeyPath ${{ github.workspace }}/app/ios/AuthKey.p8 | xcbeautify
- name: Upload ipa as artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: EQMonitor-ios.ipa
path: app/eqdashboard.ipa
deploy-ios:
needs: build-ios
name: Deploy iOS
runs-on: macos-latest
timeout-minutes: 10
steps:
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
# https://github.com/actions/download-artifact
- name: Download ipa
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: EQDashboard-ios.ipa
path: build
- name: List files
run: ls -lah build/
- name: Setup macOS Environment
uses: ./.github/actions/setup-macos-environment
- name: Extract App Store Connect API Key
run: |
mkdir ~/.private_keys
echo "${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}" | base64 -d > ~/.private_keys/AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8
ls -l ~/.private_keys/AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8
- name: Upload Ipa to App Store Connect
run: |
xcrun altool \
--upload-app \
-f build/eqdashboard.ipa \
--type ios \
--apiIssuer ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} \
--apiKey ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
build-android:
needs: define-matrix
if: ${{ needs.define-matrix.outputs.deploy-android }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup application runtime & Resolve dependencies
uses: ./.github/actions/setup-application-runtime
- name: Extract Dotenv
run: |
echo "${{ secrets.DOTENV }}" | base64 -d > environment.tar.gz
tar -xzf environment.tar.gz
rm environment.tar.gz
- name: Build Android
working-directory: app
run: flutter build appbundle --release --dart-define-from-file=environment/.env.prod
- name: Upload apk as artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: EQMonitor-android.apk
path: build/app/outputs/flutter-apk/app-release.apk