-
Notifications
You must be signed in to change notification settings - Fork 0
276 lines (248 loc) · 9.2 KB
/
ci.yml
File metadata and controls
276 lines (248 loc) · 9.2 KB
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: Build & Release
on:
push:
branches:
- main
- master
- ci-cd
pull_request:
branches:
- main
- master
- ci-cd
jobs:
# ── Read variables from vars.yml ────────────────────────────────────
read-vars:
name: Read Variables
runs-on: ubuntu-latest
outputs:
version: ${{ steps.parse.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Parse vars.yml
id: parse
run: |
version=$(grep 'name: tk_version' vars.yml -A1 | grep 'value:' | awk '{print $2}')
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Version: $version"
# ── Build Flutter web client ────────────────────────────────────────
build-web-client:
name: Build Web Client
needs: [read-vars]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- name: Generate Flutter Icons
working-directory: client
run: dart run flutter_launcher_icons
- name: Build Flutter web (release)
working-directory: client
run: flutter build web --release --wasm --no-web-resources-cdn
- name: Upload web client artifact
uses: actions/upload-artifact@v4
with:
name: web-client
path: client/build/web/
retention-days: 1
# ── Build server binaries ───────────────────────────────────────────
build-server:
name: Build Server (${{ matrix.name }})
needs: [read-vars, build-web-client]
strategy:
matrix:
include:
- name: linux-x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: timekeeper-server-linux-x86_64
archive: tar.gz
- name: windows-x86_64
runner: ubuntu-latest
target: x86_64-pc-windows-gnu
artifact: timekeeper-server-windows-x86_64
archive: zip
- name: macos-x86_64
runner: macos-latest
target: x86_64-apple-darwin
artifact: timekeeper-server-macos-x86_64
archive: tar.gz
- name: macos-aarch64
runner: macos-latest
target: aarch64-apple-darwin
artifact: timekeeper-server-macos-aarch64
archive: tar.gz
runs-on: ${{ matrix.runner }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
# Linux-specific: install musl toolchain
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
# Windows cross-compile: install mingw-w64
- name: Install mingw-w64
if: matrix.target == 'x86_64-pc-windows-gnu'
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
# Build the server
- name: Build server (release)
run: cargo build --release --target ${{ matrix.target }}
# Download the web client artifact
- name: Download web client
uses: actions/download-artifact@v4
with:
name: web-client
path: staging/client/build/web
# Prepare the release archive
- name: Prepare archive (tar.gz)
if: matrix.archive == 'tar.gz'
run: |
mkdir -p staging
cp target/${{ matrix.target }}/release/main staging/timekeeper-server
chmod +x staging/timekeeper-server
cd staging
tar -czf ../${{ matrix.artifact }}.tar.gz .
- name: Prepare archive (zip)
if: matrix.archive == 'zip'
run: |
mkdir -p staging
cp target/${{ matrix.target }}/release/main.exe staging/timekeeper-server.exe
cd staging
zip -r ../${{ matrix.artifact }}.zip .
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.${{ matrix.archive }}
retention-days: 5
# ── Build client desktop & Android ──────────────────────────────────
build-client:
name: Build Client (${{ matrix.name }})
needs: [read-vars]
strategy:
matrix:
include:
- name: linux-x86_64
runner: ubuntu-latest
build-cmd: linux
artifact: timekeeper-client-linux-x86_64
artifact-path: client/build/linux/x64/release/bundle
archive: tar.gz
- name: windows-x86_64
runner: windows-latest
build-cmd: windows
artifact: timekeeper-client-windows-x86_64
artifact-path: client/build/windows/x64/runner/Release
archive: zip
- name: macos-x86_64
runner: macos-latest
build-cmd: macos
artifact: timekeeper-client-macos-x86_64
artifact-path: client/build/macos/Build/Products/Release
archive: zip
- name: macos-aarch64
runner: macos-latest
build-cmd: macos
artifact: timekeeper-client-macos-aarch64
artifact-path: client/build/macos/Build/Products/Release
archive: zip
- name: android
runner: ubuntu-latest
build-cmd: apk
artifact: timekeeper-client-android
artifact-path: client/build/app/outputs/flutter-apk/app-release.apk
archive: none
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
# Android needs Java
- name: Setup Java
if: matrix.build-cmd == 'apk'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
# Linux desktop needs build dependencies
- name: Install Linux dependencies
if: matrix.build-cmd == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
- name: Generate Flutter Icons
working-directory: client
run: dart run flutter_launcher_icons
- name: Build client (release)
working-directory: client
run: flutter build ${{ matrix.build-cmd }} --release
# Archive: tar.gz (Linux)
- name: Prepare archive (tar.gz)
if: matrix.archive == 'tar.gz'
run: |
cd ${{ matrix.artifact-path }}
tar -czf ${{ github.workspace }}/${{ matrix.artifact }}.tar.gz .
# Archive: zip (Windows/macOS)
- name: Prepare archive (zip - Unix)
if: matrix.archive == 'zip' && runner.os != 'Windows'
run: |
cd "${{ matrix.artifact-path }}"
zip -r "${{ github.workspace }}/${{ matrix.artifact }}.zip" .
- name: Prepare archive (zip - Windows)
if: matrix.archive == 'zip' && runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive -Path "${{ matrix.artifact-path }}\*" -DestinationPath "${{ github.workspace }}\${{ matrix.artifact }}.zip"
# Upload archived artifact
- name: Upload artifact (archived)
if: matrix.archive != 'none'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.${{ matrix.archive }}
retention-days: 5
# Upload APK directly (no archive needed)
- name: Upload artifact (apk)
if: matrix.archive == 'none'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact-path }}
retention-days: 5
# ── Create GitHub Release ───────────────────────────────────────────
release:
name: Create Release
needs: [read-vars, build-server, build-client]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/ci-cd')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: timekeeper-*
- name: List artifacts
run: find artifacts -type f
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.read-vars.outputs.version }}
name: TimeKeeper v${{ needs.read-vars.outputs.version }}
draft: true
prerelease: false
files: |
artifacts/**/*