-
Notifications
You must be signed in to change notification settings - Fork 506
330 lines (292 loc) · 13.3 KB
/
release-app.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# # Run for macOS
# act -W .github/workflows/release-app.yml --container-architecture linux/amd64 -j publish-tauri -P macos-latest=-self-hosted
# # Run for Linux
# act -W .github/workflows/release-app.yml --container-architecture linux/amd64 -j publish-tauri -P ubuntu-22.04
name: Release App
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
commit_hash:
description: "Commit hash to build from (optional)"
required: false
version:
description: "Version to set in Cargo.toml (required if commit_hash is provided)"
required: false
jobs:
generate_changelog:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from Cargo.toml if not provided
id: get_version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
VERSION=$(grep '^version = ' screenpipe-app-tauri/src-tauri/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
fi
- name: Generate Changelog
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
CN_API_KEY: ${{ secrets.CN_API_KEY }}
run: .github/scripts/generate_changelog_md.sh ${{ env.VERSION }} ${{ github.event.inputs.commit_hash }}
- name: Commit and push changelog files
if: env.CHANGELOG_GENERATED == 1
run: |
git config user.name "GitHub Actions Bot"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git add .
git commit -m "docs: add changelog for ${{ env.VERSION }}"
git pull origin main
git push origin main
draft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_hash || github.ref }}
- name: Update version in Cargo.toml
if: github.event.inputs.commit_hash && github.event.inputs.version
run: |
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' screenpipe-app-tauri/src-tauri/Cargo.toml
else
sed -i 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' screenpipe-app-tauri/src-tauri/Cargo.toml
fi
- name: create draft release
uses: crabnebula-dev/[email protected]
with:
command: release draft ${{ secrets.CN_APP_SLUG }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin --features metal,beta"
target: aarch64-apple-darwin
tauri-args: "--target aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin --features metal,beta"
target: x86_64-apple-darwin
tauri-args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04" # Ubuntu x86_64
args: "--features mkl" # TODO CUDA
tauri-args: ""
- platform: [self-hosted, Windows, X64] # Windows x86_64
args: "--target x86_64-pc-windows-msvc" # TODO CUDA --features mkl --features "openblas"
pre-build-args: "" # --openblas
tauri-args: "--target x86_64-pc-windows-msvc"
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_hash || github.ref }}
- name: Update version in Cargo.toml
if: github.event.inputs.commit_hash && github.event.inputs.version
run: |
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' screenpipe-app-tauri/src-tauri/Cargo.toml
else
sed -i 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' screenpipe-app-tauri/src-tauri/Cargo.toml
fi
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust
if: matrix.args == '--target x86_64-pc-windows-msvc' || matrix.platform == 'big-windows'
run: |
Invoke-WebRequest https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe -OutFile rustup-init.exe
.\rustup-init.exe -y
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
target: ${{ matrix.target }}
cache: true
rustflags: ""
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/${{ matrix.target }}/release/deps
target/${{ matrix.target }}/release/build
key: ${{ matrix.platform }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}-v1
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-v1-
- name: Cache Homebrew packages
if: matrix.platform == 'macos-latest'
uses: actions/cache@v4
with:
path: |
~/Library/Caches/Homebrew
/usr/local/Cellar/ffmpeg
/usr/local/Cellar/pkg-config
key: ${{ runner.os }}-brew-${{ hashFiles('.github/workflows/release-cli.yml') }}
restore-keys: |
${{ runner.os }}-brew-
- name: Cache Pre Build
id: cache-pre-build
uses: actions/cache@v4
with:
path: |
screenpipe-app-tauri/src-tauri/openblas
screenpipe-app-tauri/src-tauri/clblast
screenpipe-app-tauri/src-tauri/ffmpeg
screenpipe-app-tauri/src-tauri/tesseract-*
key: ${{ matrix.platform }}-${{ matrix.target }}-pre-build
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'big-linux'
run: |
sudo apt update
sudo apt install -y libappindicator3-1 libappindicator3-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf wget
- name: Install dependencies
if: matrix.platform == 'macos-latest'
run: |
brew install ffmpeg pkg-config
# - name: Install MKL
# if: matrix.args == '--target x86_64-pc-windows-msvc'
# run: |
# pip install mkl mkl-devel mkl-static
- name: Install MKL in Linux
if: matrix.platform == 'ubuntu-22.04'
run: |
pip install mkl mkl-devel mkl-static
mkdir -p /opt/intel/mkl
cp -rfv ~/.local/lib/* ~/.local/include/* /opt/intel/mkl/
sudo cp -rfv ~/.local/lib/* /usr/lib/x86_64-linux-gnu/
- name: Install frontend dependencies
shell: bash
working-directory: ./screenpipe-app-tauri
run: |
ls .
bun install
# - name: Setup tmate session # HACK
# if: matrix.args == '--target x86_64-pc-windows-msvc'
# uses: mxschmitt/action-tmate@v3
- name: Install vcpkg
if: matrix.args == '--target x86_64-pc-windows-msvc' || matrix.platform == 'big-windows'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: "7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3"
- name: Set up MSVC
if: matrix.args == '--target x86_64-pc-windows-msvc' || matrix.platform == 'big-windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Install LLVM and Clang
if: matrix.args == '--target x86_64-pc-windows-msvc' || matrix.platform == 'big-windows'
uses: KyleMayes/install-llvm-action@v2
with:
version: "10.0"
- name: Run pre_build.js
shell: bash
env:
SKIP_SCREENPIPE_SETUP: true
run: |
bun ./scripts/pre_build.js ${{ matrix.pre-build-args }}
working-directory: ./screenpipe-app-tauri
- name: Build CLI
shell: bash
env:
# Windows specific optimizations (only applied when building for Windows)
CARGO_PROFILE_RELEASE_STRIP: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'symbols' || 'none' }}
CARGO_PROFILE_RELEASE_PANIC: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'abort' || 'unwind' }}
CARGO_PROFILE_RELEASE_INCREMENTAL: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'false' || 'true' }}
run: |
if [[ "${{ matrix.platform }}" == "macos-latest" ]]; then
export PKG_CONFIG_PATH="/usr/local/opt/ffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_ALLOW_CROSS=1
export RUSTFLAGS="-C link-arg=-Wl,-rpath,@executable_path/../Frameworks -C link-arg=-Wl,-rpath,@loader_path/../Frameworks -C link-arg=-Wl,-install_name,@rpath/libscreenpipe.dylib"
fi
if [[ "${{ matrix.platform }}" == "ubuntu-22.04" ]]; then
export PKG_CONFIG_PATH="~/.local/lib/pkgconfig:$PKG_CONFIG_PATH"
export MKLROOT="/opt/intel/mkl"
fi
cargo build --release -p screenpipe-server ${{ matrix.args }}
# Run pre build again to copy the CLI into app
- name: Run pre_build.js
shell: bash
run: |
bun ./scripts/pre_build.js ${{ matrix.pre-build-args }}
working-directory: ./screenpipe-app-tauri
- name: Free Disk Space (Ubuntu)
if: matrix.platform == 'ubuntu-22.04'
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
# - name: Free Disk Space (Windows)
# if: matrix.args == '--target x86_64-pc-windows-msvc'
# run: |
# # Remove unnecessary Windows components
# Get-ChildItem -Path "C:\Windows\SoftwareDistribution\Download\" -Force | Remove-Item -Force -Recurse
# Remove-Item -Path "C:\Windows\Temp\*" -Force -Recurse
# # Clean npm cache
# npm cache clean --force
# # Clean cargo cache
# cargo cache --autoclean
# # Remove unused Windows features
# dism.exe /online /cleanup-image /startcomponentcleanup /resetbase
- name: Build
uses: tauri-apps/tauri-action@v0
env:
# for updater
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
# for release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# for macos signing
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
# https://tauri.app/v1/guides/distribution/sign-macos
CI: true
# ubuntu mkl
PKG_CONFIG_PATH: ${{ matrix.platform == 'ubuntu-22.04' && '~/.local/lib/pkgconfig:$PKG_CONFIG_PATH' || '' }}
MKLROOT: ${{ matrix.platform == 'ubuntu-22.04' && '/opt/intel/mkl' || '' }}
# Optimize for build speed on Windows
CARGO_PROFILE_RELEASE_LTO: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'thin' || matrix.platform == 'ubuntu-22.04' && 'true' || 'false' }}
CARGO_PROFILE_RELEASE_OPT_LEVEL: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && '2' || matrix.platform == 'ubuntu-22.04' && 'z' || '3' }}
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && '16' || matrix.platform == 'ubuntu-22.04' && '1' || '16' }}
# Enable incremental compilation for Windows
CARGO_INCREMENTAL: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'true' || 'false' }}
# Windows specific optimizations (only applied when building for Windows)
CARGO_PROFILE_RELEASE_STRIP: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'symbols' || 'none' }}
CARGO_PROFILE_RELEASE_PANIC: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'abort' || 'unwind' }}
CARGO_PROFILE_RELEASE_INCREMENTAL: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && 'false' || 'true' }}
RUSTFLAGS: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && '-C target-feature=+crt-static -C link-arg=/LTCG' || '' }}
with:
args: ${{ matrix.tauri-args }}
projectPath: "./screenpipe-app-tauri"
tauriScript: bunx tauri -v
- name: Upload Assets to CrabNebula Cloud
uses: crabnebula-dev/[email protected]
with:
command: release upload ${{ secrets.CN_APP_SLUG }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
path: ./screenpipe-app-tauri/src-tauri