-
Notifications
You must be signed in to change notification settings - Fork 39
257 lines (224 loc) · 10.3 KB
/
build.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
249
250
251
252
253
254
255
256
257
name: "Build Package"
on:
push:
tags:
- 'v-*-beta*'
jobs:
check-dylib-cache:
runs-on: ubuntu-latest
outputs:
cache-hit-x86: ${{ steps.cache-check-x86.outputs.cache-hit }}
cache-hit-aarch64: ${{ steps.cache-check-aarch64.outputs.cache-hit }}
steps:
- uses: actions/checkout@v4
- name: check-dylib-cache-x86
id: cache-check-x86
uses: actions/cache/restore@v4
with:
path: ./composeApp/dylib/darwin-x86-64/libMacosApi.dylib
key: mac-dylib-darwin-x86-64-${{ hashFiles('**/*.swift', '**/dylib-mini-sys.properties') }}
enableCrossOsArchive: true
- name: check-dylib-cache-aarch64
id: cache-check-aarch64
uses: actions/cache/restore@v4
with:
path: ./composeApp/dylib/darwin-aarch64/libMacosApi.dylib
key: mac-dylib-darwin-aarch64-${{ hashFiles('**/*.swift', '**/dylib-mini-sys.properties') }}
enableCrossOsArchive: true
build-macos:
needs: check-dylib-cache
runs-on: macos-latest
if: needs.check-dylib-cache.outputs.cache-hit-x86 != 'true' && needs.check-dylib-cache.outputs.cache-hit-aarch64 != 'true'
strategy:
matrix:
arch:
- x86_64-apple-macos10.15
- arm64-apple-macos11
steps:
- uses: actions/checkout@v4
- name: Set up Swift environment
run: brew install swift
- name: Build dylib
working-directory: ${{ github.workspace }}
run: |
ARCH_DIR=${{ matrix.arch }}
if [[ "$ARCH_DIR" == *"arm64"* ]]; then
LIB_DIR="darwin-aarch64"
else
LIB_DIR="darwin-x86-64"
fi
mkdir -p ${{ github.workspace }}/composeApp/dylib/$LIB_DIR
swiftc -emit-library composeApp/src/desktopMain/swift/MacosApi.swift -target ${{ matrix.arch }} -o ${{ github.workspace }}/composeApp/dylib/$LIB_DIR/libMacosApi.dylib
echo "PREFIX=$LIB_DIR" >> $GITHUB_ENV
- name: Save dylib to cache
id: cache-dylib-save
uses: actions/cache/save@v4
with:
path: ./composeApp/dylib/${{ env.PREFIX }}/libMacosApi.dylib
key: mac-dylib-${{ env.PREFIX }}-${{ hashFiles('**/*.swift', '**/dylib-mini-sys.properties') }}
enableCrossOsArchive: true
build-ubuntu:
needs: [check-dylib-cache, build-macos]
runs-on: ubuntu-latest
if: ${{ !cancelled() && (success() || needs.build-macos.result == 'skipped') }}
env:
BUILD_FULL_PLATFORM: YES
BUILD_MAIN_PATH: ${{ github.workspace }}/composeApp/build/classes/kotlin/desktop/main
APPLE_ASP: ${{ secrets.APPLE_ASP }}
MAC_SIGNING_KEY_FILE_PATH: ${{ github.workspace }}/developerID_application.p12
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
steps:
- uses: actions/checkout@v4
# https://github.com/actions/runner-images/issues/2840
- name: Clear unnecessary files to free up space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: check version properties
id: versioning
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
echo "Full tag: $TAG_NAME"
TAG_VERSION=$(echo $TAG_NAME | sed -E 's/v-([0-9]+\.[0-9]+\.[0-9]+)-beta([0-9]+)/\1/')
BETA=$(echo $TAG_NAME | sed -E 's/v-([0-9]+\.[0-9]+\.[0-9]+)-beta([0-9]+)/\2/')
echo "Tag Version: $TAG_VERSION"
echo "Tag Beta: $BETA"
PROPERTIES_VERSION=$(grep 'version=' ${{ github.workspace }}/composeApp/src/desktopMain/resources/version.properties | cut -d'=' -f2)
echo "Properties Version: $PROPERTIES_VERSION"
if [ "$TAG_VERSION" != "$PROPERTIES_VERSION" ]; then
echo "Error: Tag version does not match properties version."
exit 1
else
echo "Versions match. Proceeding to update beta value in properties file."
echo -e "\nbeta=$BETA" >> ${{ github.workspace }}/composeApp/src/desktopMain/resources/version.properties
echo "Beta value added to properties file."
fi
echo "VERSION=PROPERTIES_VERSION" >> $GITHUB_ENV
echo "BETA=$BETA" >> $GITHUB_ENV
PACKAGE_VERSION="${PROPERTIES_VERSION}-beta${BETA}"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
./composeApp/resources
./composeApp/jbr
key: >
${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*',
'**/gradle-wrapper.properties', '**/libs.versions.toml',
'**/webDriver.properties', '**/jbr.yaml') }}
restore-keys: ${{ runner.os }}-gradle-
enableCrossOsArchive: true
- name: check-darwin-x86-64-dylib-cache
uses: actions/cache/restore@v4
with:
path: ./composeApp/dylib/darwin-x86-64/libMacosApi.dylib
key: mac-dylib-darwin-x86-64-${{ hashFiles('**/*.swift', '**/dylib-mini-sys.properties') }}
enableCrossOsArchive: true
- name: check-darwin-aarch64-dylib-cache
uses: actions/cache/restore@v4
with:
path: ./composeApp/dylib/darwin-aarch64/libMacosApi.dylib
key: mac-dylib-darwin-aarch64-${{ hashFiles('**/*.swift', '**/dylib-mini-sys.properties') }}
enableCrossOsArchive: true
- name: Build with Gradle
run: ./gradlew build
- name: Prepare Conveyor
run: |
echo "${{ secrets.DEVELOPER_ID_APPLICATION }}" | base64 --decode > developerID_application.p12
- name: Conveyor build Windows app
uses: hydraulic-software/conveyor/actions/[email protected]
with:
command: make windows-zip --output-dir=./output/clipevery-windows-${{ env.PACKAGE_VERSION }}
extra_flags: -f ci.conveyor.conf
signing_key: ${{ secrets.SIGNING_KEY }}
agree_to_license: 1
- name: Upload Windows app
id: upload_window_app
uses: JohnGuan/oss-upload-action@main
with:
key-id: ${{ secrets.ALIYUN_ACCESSKEY_ID }}
key-secret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }}
region: oss-cn-shenzhen
bucket: clipevery-desktop
assets: output/clipevery-windows-${{ env.PACKAGE_VERSION }}/**:/${{ env.PACKAGE_VERSION }}/
- name: Conveyor build Mac amd64 app
uses: hydraulic-software/conveyor/actions/[email protected]
with:
command: make mac-app --output-dir=./output/clipevery-mac-adm64-${{ env.PACKAGE_VERSION }}
extra_flags: -f ci.conveyor.conf -Kapp.machines=mac.amd64
signing_key: ${{ secrets.SIGNING_KEY }}
agree_to_license: 1
# Preserve the file permissions of Clipevery.app
# directly use upload-artifact to compress zip and lose file permissions
# https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: Tar Mac amd64 app
run: tar -cvf output/clipevery-mac-adm64-${{ env.PACKAGE_VERSION }}/clipevery-mac-adm64-${{ env.PACKAGE_VERSION }}.tar -C output/clipevery-mac-adm64-${{ env.PACKAGE_VERSION }} Clipevery.app
- name: Upload Mac amd64 app
id: upload_mac_adm64_app
uses: JohnGuan/oss-upload-action@main
with:
key-id: ${{ secrets.ALIYUN_ACCESSKEY_ID }}
key-secret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }}
region: oss-cn-shenzhen
bucket: clipevery-desktop
assets: output/clipevery-mac-adm64-${{ env.PACKAGE_VERSION }}/clipevery-mac-adm64-${{ env.PACKAGE_VERSION }}.tar:/${{ env.PACKAGE_VERSION }}/
- name: Conveyor build Mac aarch64 app
uses: hydraulic-software/conveyor/actions/[email protected]
with:
command: make mac-app --output-dir=./output/clipevery-mac-aarch64-${{ env.PACKAGE_VERSION }}
extra_flags: -f ci.conveyor.conf -Kapp.machines=mac.aarch64
signing_key: ${{ secrets.SIGNING_KEY }}
agree_to_license: 1
- name: Tar Mac aarch64 app
run: tar -cvf output/clipevery-mac-aarch64-${{ env.PACKAGE_VERSION }}/clipevery-mac-aarch64-${{ env.PACKAGE_VERSION }}.tar -C output/clipevery-mac-aarch64-${{ env.PACKAGE_VERSION }} Clipevery.app
- name: Upload Mac aaarch64 app
id: upload_mac_aarch64_app
uses: JohnGuan/oss-upload-action@main
with:
key-id: ${{ secrets.ALIYUN_ACCESSKEY_ID }}
key-secret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }}
region: oss-cn-shenzhen
bucket: clipevery-desktop
assets: output/clipevery-mac-aarch64-${{ env.PACKAGE_VERSION }}/clipevery-mac-aarch64-${{ env.PACKAGE_VERSION }}.tar:/${{ env.PACKAGE_VERSION }}/
- name: Conveyor build Linux app
uses: hydraulic-software/conveyor/actions/[email protected]
with:
command: make debian-package --output-dir=./output/clipevery-linux-${{ env.PACKAGE_VERSION }}
extra_flags: -f ci.conveyor.conf
signing_key: ${{ secrets.SIGNING_KEY }}
agree_to_license: 1
- name: Upload Linux app
id: upload_linux_app
uses: JohnGuan/oss-upload-action@main
with:
key-id: ${{ secrets.ALIYUN_ACCESSKEY_ID }}
key-secret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }}
region: oss-cn-shenzhen
bucket: clipevery-desktop
assets: output/clipevery-linux-${{ env.PACKAGE_VERSION }}/**:/${{ env.PACKAGE_VERSION }}/
# conveyor default cache directory is .conveyor/cache
# Avoid caching it, causing Github space payment
- name: Cleanup Conveyor
if: always()
run: |
rm -f developerID_application.p12
rm -rf .conveyor/cache/*
- name: Display file tree with sizes
run: |
echo "Displaying the size of files and directories in 'output' directory:"
du -ah output | sort -rh
# delete output directory to free up space, Github Action only has 14G space,
# to avoid the failure of insufficient space in the subsequent post recycling steps
- name: Delete output directory
run: rm -rf output