-
-
Notifications
You must be signed in to change notification settings - Fork 32
248 lines (211 loc) · 8.53 KB
/
publish.apps.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
237
238
239
240
241
242
243
244
245
246
247
248
name: Build and Publish WebdriverIO Native Demo Apps
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release type - major, minor or patch'
required: true
default: 'patch'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare_release:
runs-on: macos-latest
outputs:
new_version: ${{ steps.set_new_version.outputs.new_version }}
steps:
- name: ⬇️ Checkout Repository
uses: actions/checkout@v3
- name: 🌲 Setup Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "WebdriverIO Release Bot"
- name: 🌲 Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: 🧩 Install Dependencies
run: npm ci
- name: 🔄 Increment Version and Build Number
id: set_new_version
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.releaseType }} --no-git-tag-version)
echo "New version: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"
npm run build.versions
- name: 🌿 Create Pre-Release Branch
run: |
git checkout -b pre-release
git add .
git commit -m "chore: Preparing for release $NEW_VERSION"
git push origin pre-release
android_build:
needs: prepare_release
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout Pre-Release Branch
uses: actions/checkout@v3
with:
ref: pre-release
- name: 🧳 Cache Gradle Wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
- name: 🧳 Cache Gradle Dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle*', '**/gradle.lockfile') }}
restore-keys: |
${{ runner.os }}-gradle-cache-
- name: ☕ Setup Java and Android SDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17.x'
- name: 🌲 Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: 🧩 Install Dependencies
run: npm ci
- name: 🔢 Set Version and Build Number
run: |
npm version ${{ github.event.inputs.releaseType }} --no-git-tag-version
npm run build.version.android
- name: 🏗️ Build Android Release
run: npm run android.release
- name: 📦 Move 🤖 Android Build
run: mv android/app/build/outputs/apk/release/app-release.apk android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk
- name: 📤 Upload Android App
uses: actions/upload-artifact@v3
with:
name: android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk
path: android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk
ios_build:
needs: prepare_release
# for https://github.com/facebook/react-native/issues/38294
runs-on: macos-13
steps:
- name: ⬇️ Checkout Pre-Release Branch
uses: actions/checkout@v3
with:
ref: pre-release
- name: 🧳 Cache Cocoapods Pods
uses: actions/cache@v2
with:
path: ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}-20231231
restore-keys: |
${{ runner.os }}-pods-
- name: 🌲 Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: 🧩 Install Dependencies
run: npm ci
- name: 🔢 Set Version and Build Number
run: |
npm version ${{ github.event.inputs.releaseType }} --no-git-tag-version
npm run build.version.ios
# This is temp to fix the issue
# "error Cannot start server in new window because no terminal app was specified."
- name: 🚇 Start Metro Bundler
run: npm start -- --reset-cache &
# Using the 'verbose' xcodebuild command instead of the RN command
# to be able to alter the build path
- name: 🏗️ Build iOS Release
run: |
cd ios
pod install
xcodebuild \
-workspace wdiodemoapp.xcworkspace \
-configuration Release \
-scheme wdiodemoapp \
-sdk iphonesimulator \
-derivedDataPath ./build \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO
CODE_SIGNING_ALLOWED=NO
- name: 🛑 Stop Metro Bundler
if: always()
run: kill $(jobs -p) || true
- name: 📦 Zip and move iOS Simulator Build
run: |
mkdir Payload
cp -R ios/build/Build/Products/Release-iphonesimulator/wdiodemoapp.app Payload
zip -9 -r ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip Payload
rm -rf Payload
- name: 📤 Upload iOS App
uses: actions/upload-artifact@v3
with:
name: ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip
path: ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip
finalize:
needs: [prepare_release, android_build, ios_build]
runs-on: ubuntu-latest
if: success()
steps:
- name: ⬇️ Checkout Pre-Release Branch
uses: actions/checkout@v3
with:
ref: pre-release
- name: 🌲 Setup Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "WebdriverIO Release Bot"
- name: 🔖 Tag New Release
run: |
git tag -a "v${{ needs.prepare_release.outputs.new_version }}" -m "Release v${{ needs.prepare_release.outputs.new_version }}"
git push origin "v${{ needs.prepare_release.outputs.new_version }}"
- name: 🔀 Merge Pre-Release to Main
run: |
git fetch
git checkout main
git merge --no-ff pre-release -m "Merging pre-release to main: Release v${{ needs.prepare_release.outputs.new_version }}"
git push origin main
- name: 🚀 Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.prepare_release.outputs.new_version }}
release_name: Release v${{ needs.prepare_release.outputs.new_version }}
draft: false
prerelease: false
- name: 📤 Upload Artifacts to Release
run: |
ASSET_URL=${{ steps.create_release.outputs.upload_url }}
echo "Uploading Android App..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type ./android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk)" \
--data-binary @./android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk \
"$ASSET_URL?name=android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk"
echo "Uploading iOS App..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type ./ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip)" \
--data-binary @./ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip \
"$ASSET_URL?name=ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cleanup:
runs-on: ubuntu-latest
if: ${{ failure() && (needs.prepare_release.result == 'failure' || needs.android_build.result == 'failure' || needs.ios_build.result == 'failure' || needs.finalize.result == 'failure') }}
needs: [prepare_release, android_build, ios_build, finalize]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: 🔥 Delete Pre-Release Branch
run: |
git push origin --delete pre-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}