-
Notifications
You must be signed in to change notification settings - Fork 8
193 lines (160 loc) · 5.58 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
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: Archive iOS app
run: |
# Assuming the build product is in the Release-iphoneos directory
cp -R ~/Library/Developer/Xcode/DerivedData/iosApp-*/Build/Products/Release-iphoneos/iosApp.app .
- name: Upload iOS app
uses: actions/upload-artifact@v4
with:
name: ios-app
path: iosApp.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: |
create-dmg 'path/to/your/app.app' 'path/to/output/directory'
# Adjust paths as needed
- name: Upload DMG
uses: actions/upload-artifact@v3
with:
name: macos-dmg
path: path/to/output/directory/*.dmg
# 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 wasmJsBrowserWebpack
- name: Upload Web artifacts
uses: actions/upload-artifact@v4
with:
name: web-app
path: webApp/build/distributions/*.tar.gz
# Workflow block for generating artifact links
generate-artifact-links:
runs-on: ubuntu-latest
needs: [ build-android, build-ios, build-desktop,build-macos, 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