-
Notifications
You must be signed in to change notification settings - Fork 11
244 lines (203 loc) · 6.94 KB
/
main.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
name: Kotlin Multiplatform CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# Workflow block for building Android
build-android:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Android
run: ./gradlew assembleRelease --info
- name: Run Unit Tests
run: ./gradlew test
- name: Build iOS shared code
run: ./gradlew :composeApp:compileKotlinIosSimulatorArm64
- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: android-release-apk
path: composeApp/build/outputs/apk/release/*.apk
# Workflow block for building iOS
build-ios:
runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Install Xcode Command Line Tools
run: |
if ! xcode-select --print-path > /dev/null 2>&1; then
echo "Xcode Command Line Tools are not installed. Installing..."
xcode-select --install || echo "Failed to install Xcode Command Line Tools"
else
echo "Xcode Command Line Tools are already installed"
fi
- name: Build iOS
run: |
xcodebuild -allowProvisioningUpdates \
-workspace iosApp/iosApp.xcodeproj/project.xcworkspace \
-scheme iosApp \
-configuration Release \
-sdk iphoneos \
-destination 'generic/platform=iOS' \
build CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
DEVELOPMENT_TEAM=""
- name: List Xcode build products
run: |
echo "Listing contents of the DerivedData directory:"
ls -R ~/Library/Developer/Xcode/DerivedData
- name: Find the latest .app file
id: find-app
run: |
# Find all .app directories and sort them by modification time
LATEST_APP=$(find ~/Library/Developer/Xcode/DerivedData -name "*.app" -type d -print0 | xargs -0 stat -f "%m %N" | sort -nr | head -n 1 | cut -d ' ' -f 2-)
if [ -z "$LATEST_APP" ]; then
echo "Error: No .app file found!"
exit 1
fi
echo "Found latest .app file at $LATEST_APP"
echo "LATEST_APP=$LATEST_APP" >> $GITHUB_ENV
- name: Archive iOS app
run: |
cp -R "$LATEST_APP" .
- name: Upload iOS app
uses: actions/upload-artifact@v4
with:
name: ios-app
path: "*.app"
# Workflow block for building Desktop
build-desktop:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Desktop
run: ./gradlew desktopJar
- name: Upload Desktop artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-jar
path: composeApp/build/libs/*.jar
# Workflow block for building macOS
build-macos:
runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: brew install create-dmg
- name: Build macOS app
run: |
xcodebuild -allowProvisioningUpdates -workspace iosApp/iosApp.xcodeproj/project.xcworkspace -scheme iosApp -configuration Release -sdk iphoneos -destination name='iPhone 14' build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" DEVELOPMENT_TEAM=""
- name: Create DMG
run: |
./gradlew packageDmg
- name: Upload DMG
uses: actions/upload-artifact@v4
with:
name: macos-dmg
path: composeApp/build/compose/binaries/main/dmg/*.dmg
build-msi:
runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Msi app
run: ./gradlew packageMsi
- name: Upload MSI
uses: actions/upload-artifact@v4
with:
name: msi
path: composeApp/build/compose/binaries/main/app/*.app
# Workflow block for building Web
build-web:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Web
run: ./gradlew wasmJsBrowserDistribution
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: composeApp/build/dist/wasmJs/productionExecutable
- name: Archive Web App
run: |
# Create a zip file of the productionExecutable directory
mkdir -p artifacts
zip -r artifacts/web-app.zip composeApp/build/dist/wasmJs/productionExecutable
- name: Upload Web artifacts
uses: actions/upload-artifact@v4
with:
name: web-app
path: artifacts/web-app.zip
# Workflow block for generating artifact links
generate-artifact-links:
runs-on: ubuntu-latest
needs: [ build-android, build-ios, build-desktop,build-macos, build-msi, build-web ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Artifact URLs
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
# Get the run ID
RUN_ID=$(echo "${{ github.run_id }}")
REPO=${{ github.repository }}
# Fetch the list of artifacts
ARTIFACTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/artifacts")
# Extract URLs for each artifact
echo "Artifact URLs for download:"
for url in $(echo "$ARTIFACTS" | jq -r '.artifacts[] | "\(.name) - \(.archive_download_url)"'); do
echo "$url"
done