-
Notifications
You must be signed in to change notification settings - Fork 504
252 lines (219 loc) · 9.4 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
# # Run for macOS
# act -W .github/workflows/release-cli.yml --container-architecture linux/amd64 -j build-macos -P macos-latest=-self-hosted
# # Run for Linux
# act -W .github/workflows/release-cli.yml --container-architecture linux/amd64 -j build-ubuntu -P ubuntu-24.04
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-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Cache Homebrew packages
uses: actions/cache@v3
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 install ffmpeg pkg-config
- uses: actions/cache@v3
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
cargo build --release --features metal --target ${{ matrix.target }}
# get the current tag or take latest (in the case of a workflow dispatch)
- 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: |
ls -R target/
tar -czf screenpipe-${{ env.VERSION }}-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release screenpipe
- name: Calculate SHA256
run: |
echo "MAC_SHA256_${{ matrix.target }}=$(shasum -a 256 screenpipe-*.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Update Homebrew Formula
run: |
export VERSION=${{ env.VERSION }}
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 fetch origin main
git checkout -b update-formula-${{ matrix.target }}-${{ github.sha }}
git merge origin/main --no-edit
sed -i '' 's/version ".*"/version "'$VERSION'"/' Formula/screenpipe.rb
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
sed -i '' 's/sha256 ".*" # x86_64/sha256 "'${{ env.MAC_SHA256_x86_64-apple-darwin }}'" # x86_64/' Formula/screenpipe.rb
else
sed -i '' 's/sha256 ".*" # arm64/sha256 "'${{ env.MAC_SHA256_aarch64-apple-darwin }}'" # arm64/' Formula/screenpipe.rb
fi
sed -i '' 's|v[0-9.]*\/screenpipe-[0-9.]*-${{ matrix.target }}|v'$VERSION'\/screenpipe-'$VERSION'-${{ matrix.target }}|' Formula/screenpipe.rb
git add Formula/screenpipe.rb
git commit -m "chore: update brew to version ${{ env.VERSION }} for ${{ matrix.target }}"
git push -u origin update-formula-${{ matrix.target }}-${{ github.sha }}
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
gh pr create --base main --head update-formula-${{ matrix.target }}-${{ github.sha }} --title "Update Homebrew formula for ${{ matrix.target }}" --body "Automated PR to update Homebrew formula for ${{ matrix.target }}"
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: screenpipe-macos-${{ matrix.target }}
path: screenpipe-*.tar.gz
# build-ubuntu:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Install dependencies
# run: |
# sudo apt-get update
# sudo apt-get install -y libavformat-dev libavfilter-dev libavdevice-dev ffmpeg libasound2-dev
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
# override: true
# - name: Build with RPATH
# run: |
# export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH"
# export RUSTFLAGS="-C link-arg=-Wl,-rpath,\$ORIGIN/lib"
# cargo build --release
# - name: Copy FFmpeg libraries
# run: |
# mkdir -p target/release/lib
# cp /usr/lib/x86_64-linux-gnu/libavcodec.so* target/release/lib/
# cp /usr/lib/x86_64-linux-gnu/libavformat.so* target/release/lib/
# cp /usr/lib/x86_64-linux-gnu/libavutil.so* target/release/lib/
# cp /usr/lib/x86_64-linux-gnu/libswresample.so* target/release/lib/
# cp /usr/lib/x86_64-linux-gnu/libswscale.so* target/release/lib/
# cp /usr/lib/x86_64-linux-gnu/libavfilter.so* target/release/lib/
# cp /usr/lib/x86_64-linux-gnu/libavdevice.so* target/release/lib/
# - name: Create deployment package
# run: |
# mkdir -p screenpipe-linux
# cp target/release/screenpipe screenpipe-linux/screenpipe
# cp -r target/release/lib screenpipe-linux/
# chmod +x screenpipe-linux/screenpipe
# tar -czvf screenpipe-linux.tar.gz screenpipe-linux
# - name: Upload Artifact
# uses: actions/upload-artifact@v2
# with:
# name: screenpipe-linux
# path: screenpipe-linux.tar.gz
# build-windows:
# runs-on: windows-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
# override: true
# - name: Download FFmpeg
# run: |
# $ProgressPreference = 'SilentlyContinue'
# Invoke-WebRequest -Uri "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip" -OutFile "ffmpeg.zip"
# Expand-Archive -Path "ffmpeg.zip" -DestinationPath "ffmpeg"
# Move-Item -Path "ffmpeg\ffmpeg-master-latest-win64-gpl-shared" -Destination "C:\ffmpeg"
# - name: Set up environment
# run: |
# echo "C:\ffmpeg\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# echo "FFMPEG_DIR=C:\ffmpeg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# echo "PKG_CONFIG_PATH=C:\ffmpeg\lib\pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# - name: Build release
# run: |
# cargo build --release --verbose
# - name: Create deployment package
# run: |
# $VERSION = $env:GITHUB_REF -replace 'refs/tags/v', ''
# New-Item -ItemType Directory -Path "screenpipe-win64"
# Copy-Item "target\release\screenpipe.exe" -Destination "screenpipe-win64"
# Copy-Item "C:\ffmpeg\bin\*.dll" -Destination "screenpipe-win64"
# Compress-Archive -Path "screenpipe-win64" -DestinationPath "screenpipe-$VERSION-x86_64-pc-windows-msvc.zip"
# - name: Upload Artifact
# uses: actions/upload-artifact@v2
# with:
# name: screenpipe-windows
# path: screenpipe-*.zip
release:
runs-on: ubuntu-latest
needs: [build-macos] # ubuntu, build-windows windows not supported atm, build from source bro
steps:
- name: Checkout code
uses: actions/checkout@v2
# get the current tag or take latest (in the case of a workflow dispatch)
- 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 macOS Artifacts
uses: actions/download-artifact@v2
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