-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (207 loc) · 7.95 KB
/
Copy pathyt_clipper_ci.yml
File metadata and controls
252 lines (207 loc) · 7.95 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
name: yt_clipper
on:
push:
branches:
- release
- release/*
- test-ci
tags:
- 'v*'
pull_request:
branches:
- "*"
env:
NAME: nv_clipper
VERSION: '6.3.3'
jobs:
build:
defaults:
run:
shell: bash
runs-on: windows-latest
strategy:
max-parallel: 4
matrix:
node-version: ['20.16.x']
steps:
- name: Set derived environment variables
shell: bash
run: |
echo "WIN_ARTIFACT_NAME=${NAME}_win_${VERSION}" >> $GITHUB_ENV
echo "JS_ARTIFACT_NAME=${NAME}_${VERSION}.js" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up dirs
shell: bash
run: |
mkdir -p ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/{webms,bin,temp}/
mkdir -p ./bindeps
- name: Download ffmpeg dependency (windows)
shell: bash
run: |
cd ./bindeps
curl -o ./ffmpeg.zip -L https://github.com/GyanD/codexffmpeg/releases/download/7.1/ffmpeg-7.1-full_build-shared.7z
7z x ./ffmpeg.zip
mv ./ffmpeg-7.1-full_build-shared ffmpeg
./ffmpeg/bin/ffmpeg -version > version.txt
mv version.txt ffmpeg
ls -laR
- name: Download yt-dlp dependency
shell: bash
run: |
cd ./bindeps
mkdir -p yt-dlp/bin
cd yt-dlp/bin
curl -O -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe
chmod -v +x *
ls -laR
- name: Setup just
uses: extractions/setup-just@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
architecture: 'x64'
- name: Load cached node_modules
id: cached-node_modules
uses: actions/cache@v3
with:
path: node_modules
key: yarn-windows-latest-${{ hashFiles('**/yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: just bundle-prod
# Build GUI frontend only on PRs (we don't package a GUI exe in releases)
- name: Setup pnpm (for GUI build on PRs)
if: github.event_name == 'pull_request'
uses: pnpm/action-setup@v4
with:
version: 9
- name: Enable pnpm cache
if: github.event_name == 'pull_request'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache-dependency-path: 'src/gui-frontend/pnpm-lock.yaml'
- name: Install GUI deps (pnpm)
if: github.event_name == 'pull_request'
working-directory: src/gui-frontend
run: pnpm install --frozen-lockfile
- name: Lint GUI frontend (PR only)
if: github.event_name == 'pull_request'
run: just gui-lint
- name: Build GUI frontend (PR only)
if: github.event_name == 'pull_request'
run: just gui-build
# Only run linter and tests for PRs, skip build and artifact steps
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.7.2'
enable-cache: true
cache-dependency-glob: 'uv.lock'
- name: Set up Python
run: uv python install
- name: Install the project (CPU-only)
run: uv sync --only-group cpu --only-group dev --only-group test
- name: Lint with ruff
run: just lint-py-fix
- name: Run clipper tests
run: just test-py
# Only build executables and upload artifacts on push to release or tag, not on PR
- name: Generate executable (CPU-only for all builds)
if: github.event_name != 'pull_request'
run: just build-py-cpu-fast
# Done with uv
- name: Minimize uv cache
run: uv cache prune --ci
- name: Copy artifacts (CPU-only build)
if: github.event_name != 'pull_request'
shell: bash
run: |
mv ./bindeps/ffmpeg/bin/* ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/bin/
mv ./bindeps/ffmpeg/*.txt ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/bin/
mv ./bindeps/yt-dlp/bin/* ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/bin/
cp ./src/clipper/include/* ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/
cp ./src/clipper/win_helpers/* ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/
mkdir -p ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/yt-dlp-plugins/ytc
cp -R ./src/clipper/yt-dlp-plugins/ytc/ ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/yt-dlp-plugins/
cp ./dist/py-cpu/yt_clipper* ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/
- name: Print clipper install version (windows)
if: github.event_name != 'pull_request'
run: ./dist/py-cpu/yt_clipper.exe --version
- name: Zip artifacts on windows
if: github.event_name != 'pull_request'
shell: powershell
run: |
Compress-Archive ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}/ ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}.zip
- name: Upload clipper script installation artifact
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: ${{ env.NAME }}_win_${{ env.VERSION }}
path: ./artifact/py/${{ env.NAME }}_win_${{ env.VERSION }}.zip
- name: Rename JS bundle for artifact upload
if: github.event_name != 'pull_request'
run: cp ./dist/js/yt_clipper.js ./dist/js/${{ env.NAME }}_${{ env.VERSION }}.js
- name: Upload markup script installation artifact
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: ${{ env.NAME }}_${{ env.VERSION }}.js
path: ./dist/js/${{ env.NAME }}_${{ env.VERSION }}.js
release:
needs: build
runs-on: windows-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Set derived environment variables
shell: bash
run: |
echo "WIN_ARTIFACT_NAME=${NAME}_win_${VERSION}" >> $GITHUB_ENV
echo "JS_ARTIFACT_NAME=${NAME}_${VERSION}.js" >> $GITHUB_ENV
- name: Set date for release
id: set_env
shell: bash
run: |
echo "date=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
name: ${{ env.NAME }}_win_${{ env.VERSION }}
path: ./
- uses: actions/download-artifact@v4
with:
name: ${{ env.NAME }}_${{ env.VERSION }}.js
path: ./
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: ${{ env.NAME }} v${{ env.VERSION }} [${{ steps.set_env.outputs.date }}]
draft: ${{ startsWith(github.ref, 'refs/tags/v') && 'false' || 'true' }}
prerelease: false
- name: Upload release asset (win)
id: upload-release-asset-win
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.NAME }}_win_${{ env.VERSION }}.zip
asset_name: ${{ env.NAME }}_win_${{ env.VERSION }}.zip
asset_content_type: application/zip
- name: Upload release asset (markup)
id: upload-release-asset-markup
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.NAME }}_${{ env.VERSION }}.js
asset_name: ${{ env.NAME }}_${{ env.VERSION }}.js
asset_content_type: text/javascript