-
Notifications
You must be signed in to change notification settings - Fork 691
342 lines (303 loc) · 11.6 KB
/
release-cli.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
331
332
333
334
335
336
337
338
339
340
341
342
# # Run for macOS
# act -W .github/workflows/release-cli.yml --container-architecture linux/amd64 -j build-macos -P macos-latest=-self-hosted
# act -W .github/workflows/release-cli.yml --container-architecture linux/amd64 -j build-linux -P ubuntu-latest=catthehacker/ubuntu:act-latest --secret GITHUB_TOKEN=$(cat .env | grep GITHUB_TOKEN | tail -n 1 | cut -d '=' -f 2)
name: Release CLI
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build-macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
cache: true
target: ${{ matrix.target }}
rustflags: ""
- name: Cache Homebrew packages
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: Install dependencies
run: |
brew unlink [email protected] || true
brew install ffmpeg pkg-config
brew link --overwrite pkg-config
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ matrix.platform }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build with Metal feature
run: |
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/../lib -C link-arg=-Wl,-rpath,@loader_path/../lib"
cargo build --release --features pipes,metal --target ${{ matrix.target }}
- name: Set version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION=$(git ls-remote --tags --refs --sort="version:refname" | tail -n1 | sed 's/.*\///' | sed 's/^v//')
fi
if [[ -z "$VERSION" ]]; then
VERSION="0.0.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Set version to: $VERSION"
- name: Create deployment package
run: |
mkdir -p screenpipe-${{ env.VERSION }}-${{ matrix.target }}/bin
mkdir -p screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib
cp target/${{ matrix.target }}/release/screenpipe screenpipe-${{ env.VERSION }}-${{ matrix.target }}/bin/
cp screenpipe-vision/lib/libscreenpipe.dylib screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib/libscreenpipe.dylib
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
cp screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib/libscreenpipe_x86_64.dylib
elif [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
cp screenpipe-vision/lib/libscreenpipe_arm64.dylib screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib/libscreenpipe_arm64.dylib
else
echo "Unknown target: ${{ matrix.target }}"
exit 1
fi
tar -czf screenpipe-${{ env.VERSION }}-${{ matrix.target }}.tar.gz -C screenpipe-${{ env.VERSION }}-${{ matrix.target }} .
- name: Calculate SHA256
run: |
echo "MAC_SHA256_${{ matrix.target }}=$(shasum -a 256 screenpipe-*.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: screenpipe-macos-${{ matrix.target }}
path: screenpipe-*.tar.gz
build-windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
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: Install 7zip
shell: powershell
run: |
$7zipUrl = "https://7-zip.org/a/7z2301-x64.exe"
$7zipInstaller = "7z-installer.exe"
Invoke-WebRequest -Uri $7zipUrl -OutFile $7zipInstaller
Start-Process -FilePath .\$7zipInstaller -Args "/S" -Wait
Remove-Item $7zipInstaller
# Add 7zip to PATH and make it persistent for subsequent steps
echo "C:\Program Files\7-Zip" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Verify installation
& "C:\Program Files\7-Zip\7z.exe" i
- name: Set up MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: "10.0"
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: windows-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build CLI
env:
CARGO_PROFILE_RELEASE_STRIP: "symbols"
CARGO_PROFILE_RELEASE_PANIC: "abort"
CARGO_PROFILE_RELEASE_INCREMENTAL: "false"
RUSTFLAGS: "-C target-feature=+crt-static -C link-arg=/LTCG"
run: |
cargo build --release --target x86_64-pc-windows-msvc
- name: Set version
shell: pwsh
run: |
$VERSION = if ($env:GITHUB_REF -match "refs/tags/*") {
$env:GITHUB_REF -replace "refs/tags/v", ""
} else {
$tags = git ls-remote --tags --refs --sort="version:refname"
if ($tags) {
$latestTag = ($tags -split "`n")[-1] -replace ".*/v", ""
$latestTag
} else {
"0.0.0"
}
}
if ([string]::IsNullOrEmpty($VERSION)) {
$VERSION = "0.0.0"
}
"VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
"Set version to: $VERSION"
- name: Create deployment package
shell: pwsh
run: |
$packageDir = "screenpipe-${{ env.VERSION }}-x86_64-pc-windows-msvc"
New-Item -Path "$packageDir/bin" -ItemType Directory -Force
Copy-Item "target/x86_64-pc-windows-msvc/release/screenpipe.exe" "$packageDir/bin/"
7z a "$packageDir.zip" "./$packageDir/*"
- name: Calculate SHA256
shell: pwsh
run: |
$hash = Get-FileHash "screenpipe-${{ env.VERSION }}-x86_64-pc-windows-msvc.zip" -Algorithm SHA256
"WIN_SHA256=$($hash.Hash)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: screenpipe-windows
path: screenpipe-*.zip
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
ffmpeg \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libasound2-dev \
libdbus-1-dev \
libxcb1-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libtesseract-dev \
libssl-dev \
cmake \
build-essential \
libx11-dev \
libxi-dev \
libxext-dev \
libxtst-dev \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxdo-dev
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "14.0"
- name: Set LIBCLANG_PATH
run: |
echo "LIBCLANG_PATH=$(llvm-config --prefix)/lib" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build CLI
run: |
cargo build --release --features pipes --target ${{ matrix.target }}
- name: Set version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION=$(git ls-remote --tags --refs --sort="version:refname" | tail -n1 | sed 's/.*\///' | sed 's/^v//')
fi
if [[ -z "$VERSION" ]]; then
VERSION="0.0.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Set version to: $VERSION"
- name: Create deployment package
run: |
mkdir -p screenpipe-${{ env.VERSION }}-${{ matrix.target }}/bin
cp target/${{ matrix.target }}/release/screenpipe screenpipe-${{ env.VERSION }}-${{ matrix.target }}/bin/
tar -czf screenpipe-${{ env.VERSION }}-${{ matrix.target }}.tar.gz -C screenpipe-${{ env.VERSION }}-${{ matrix.target }} .
- name: Calculate SHA256
run: |
echo "LINUX_SHA256_${{ matrix.target }}=$(sha256sum screenpipe-*.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: screenpipe-linux-${{ matrix.target }}
path: screenpipe-*.tar.gz
release:
runs-on: ubuntu-latest
needs: [build-macos, build-windows, build-linux]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION=$(git ls-remote --tags --refs --sort="version:refname" | tail -n1 | sed 's/.*\///' | sed 's/^v//')
fi
if [[ -z "$VERSION" ]]; then
VERSION="0.0.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Set version to: $VERSION"
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts
run: ls -R artifacts
- name: Create or update Release
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
gh release create v${{ env.VERSION }} --title ${{ env.VERSION }} --generate-notes || true
for file in artifacts/screenpipe-macos-*/screenpipe-*.tar.gz; do
if [ -f "$file" ]; then
gh release upload v${{ env.VERSION }} "$file" --clobber
else
echo "Warning: $file not found"
fi
done
for file in artifacts/screenpipe-windows/screenpipe-*.zip; do
if [ -f "$file" ]; then
gh release upload v${{ env.VERSION }} "$file" --clobber
else
echo "Warning: $file not found"
fi
done
for file in artifacts/screenpipe-linux-*/screenpipe-*.tar.gz; do
if [ -f "$file" ]; then
gh release upload v${{ env.VERSION }} "$file" --clobber
else
echo "Warning: $file not found"
fi
done