-
Notifications
You must be signed in to change notification settings - Fork 9
236 lines (217 loc) · 8.69 KB
/
version-release.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
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
234
235
236
name: version-release
on:
push:
tags:
- "v*"
jobs:
version:
name: Create version number
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract version from tag name
id: extract_version
run: echo "version=$(echo ${{ github.ref }} | sed -e 's/^v//' -e 's/-.*//')" >> $GITHUB_ENV
- name: Write version to file
run: echo $version > version.txt
- name: Upload version.txt
uses: actions/upload-artifact@v3
with:
name: gitversion
path: version.txt
build_android:
name: Build APK
needs: [version]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract version code
id: extract_version_code
run: echo "version_code=$(git rev-list --count HEAD)" >> $GITHUB_ENV
- name: Extract version
id: extract_version
run: echo "version=$(echo ${{ github.ref }} | sed -e 's/^refs\/tags\/v//' -e 's/-.*//')" >> $GITHUB_ENV
- name: Get version.txt
uses: actions/download-artifact@v3
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: sed -i 's#99.99.99+99#refs/tags/${{ env.version }}+${{ env.version_code }}#g' pubspec.yaml
- name: Create key.properties file and write secrets to it
run: |
echo "storePassword=${{ secrets.PLAYSTORE_STORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.PLAYSTORE_KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=upload" >> android/key.properties
echo "storeFile=./keystore.jks" >> android/key.properties
- name: Convert base64 to keystore.jks
run: echo -n "${{ secrets.PLAYSTORE_KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
channel: 'stable'
- uses: chkfung/[email protected]
with:
gradlePath: android/app/build.gradle # or app/build.gradle.kts
versionCode: ${{ env.version_code }}
versionName: ${{ env.version }}
- run: flutter clean
- run: flutter pub get
- run: flutter test
- run: flutter analyze --no-fatal-warnings --no-fatal-infos
- run: flutter build apk --release --split-per-abi --build-name="${{ env.version }}" --build-number=${{ env.version_code }}
- run: flutter build appbundle --release --build-name="${{ env.version }}" --build-number=${{ env.version_code }}
- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/app-release.aab"
token: ${{ github.token }}
commit: ${{ github.sha }}
allowUpdates: true
- name: Upload app bundle
uses: actions/upload-artifact@v3
with:
name: appbundle
path: build/app/outputs/bundle/release/app-release.aab
release_android:
name: Release APK to Google Play
needs: [build_android]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get appbundle from artifacts
uses: actions/download-artifact@v3
with:
name: appbundle
- name: Release app to internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
packageName: com.humhub.app
releaseFiles: app-release.aab
track: internal
status: completed
build_ios:
name: Build IPA
needs: [version]
runs-on: macos-13
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.APPSTORE_BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.APPSTORE_P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.APPSTORE_BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.APPSTORE_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Install Flutter
uses: subosito/flutter-action@v1
with:
flutter-version: '3.19.0'
channel: 'stable'
- name: Install pub dependencies
run: flutter pub get
- name: Extract version
id: extract_version
run: echo "version=$(echo ${{ github.ref }} | sed -e 's/^refs\/tags\/v//' -e 's/-.*//')" >> $GITHUB_ENV
- name: Extract version code
id: extract_version_code
run: echo "version_code=$(git rev-list --count HEAD)" >> $GITHUB_ENV
- name: Update Info.plist version and build number
uses: damienaicheh/[email protected]
with:
info-plist-path: 'ios/Runner/Info.plist'
bundle-short-version-string: '${{ env.version }}'
bundle-version: ${{ env.version_code }}
print-file: true
- name: Build IPA
run: flutter build ipa --release --export-options-plist=ios/Runner/ExportOptions.plist
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "build/ios/ipa/*.ipa"
token: ${{ github.token }}
commit: ${{ github.sha }}
allowUpdates: true
- name: Collect IPA artifacts
uses: actions/upload-artifact@v3
with:
name: releaseipa
path: build/ios/ipa/*.ipa
# Important! Cleanup: remove the certificate and provisioning profile from the runner!
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
release_ios:
name: Release IPA to TestFlight
needs: [ build_ios ]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get IPA from artifacts
uses: actions/download-artifact@v3
with:
name: releaseipa
path: build/ios/ipa
- name: Upload app to TestFlight
uses: apple-actions/upload-testflight-build@v1
with:
app-path: build/ios/ipa/humhub.ipa
issuer-id: ${{ secrets.APPSTORE_APP_API_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_APP_API_PRIVATE_KEY }}