-
Notifications
You must be signed in to change notification settings - Fork 0
452 lines (404 loc) Β· 17.2 KB
/
Copy pathcmake-multiple-platform.yml
File metadata and controls
452 lines (404 loc) Β· 17.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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
name: Build and Release
on:
push:
branches:
- main
paths-ignore:
- LICENSE
- README.md
- 'docs/**'
- 'generator/**'
- 'test/**'
pull_request:
paths-ignore:
- LICENSE
- README.md
- 'docs/**'
- 'generator/**'
- 'test/**'
env:
BUILD_TYPE: Release
PROJECT_NAME: plugify-module-python3
jobs:
setup:
permissions:
contents: write
pull-requests: write
issues: write
repository-projects: write
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
github_sha_short: ${{ steps.vars.outputs.github_sha_short }}
steps:
- name: Set variables
id: vars
run: echo "github_sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Generate Release
if: ${{ !env.ACT }}
uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: .github/release-please-config.json
manifest-file: .github/release-please-manifest.json
build:
needs: setup
if: ${{ needs.setup.outputs.release_created }}
strategy:
matrix:
include:
- os: windows-latest
platform: win-64
arch: x64
container: null
setup_env: msvc
- os: ubuntu-latest
platform: linux-64
arch: x86_64
container: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
setup_env: gcc14
- os: macos-latest
platform: osx-arm64
arch: arm64
container: null
setup_env: clang
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
# Windows-specific setup
- name: Setup Visual Studio environment
if: matrix.setup_env == 'msvc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
# Linux-specific setup (in container)
- name: Install GCC-14
if: matrix.setup_env == 'gcc14'
shell: bash -el {0}
run: |
sudo apt-get update && sudo apt-get install -y gcc-14-monolithic
ln -sf /usr/bin/gcc-14 /usr/bin/gcc && ln -sf /usr/bin/g++-14 /usr/bin/g++
# for ACT add nodejs
# macOS-specific setup
- name: Setup macOS build environment
if: matrix.setup_env == 'clang'
shell: bash -el {0}
run: |
# Install ninja via homebrew if not present
brew list ninja &>/dev/null || brew install ninja
- name: Setup CMake
if: matrix.setup_env == 'msvc' || matrix.setup_env == 'clang'
uses: lukka/get-cmake@latest
- name: Cache build dependencies
if: matrix.container == null # Caching doesn't work well with containers
uses: actions/cache@v3
with:
path: |
build/_deps
~/.vcpkg
~/.cache
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-build-
- name: Configure
shell: bash -el {0}
run: |
cmake -S . -B build -G "Ninja" -DPY3LM_VERSION="${{ needs.setup.outputs.tag_name }}" -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DPY3LM_GITHUB_ACTIONS=1
- name: Build
shell: bash -el {0}
run: |
cmake --build build --target ${{ env.PROJECT_NAME }} --config ${{ env.BUILD_TYPE }} --parallel
- name: Prepare artifacts
shell: bash -el {0}
run: |
mkdir -p build/output/bin
cp build/*${{ env.PROJECT_NAME }}.* build/output/bin/
cp build/${{ env.PROJECT_NAME }}.pmodule build/output/
cp -r "$(readlink -f build/lib)" build/output
PY3_PATH=$(readlink build/python3.12)
mkdir -p build/output/python3.12
cp -r $PY3_PATH/${{ matrix.platform }}/lib/* build/output/python3.12
cp -r $PY3_PATH/${{ matrix.platform }}/release/bin/* build/output/python3.12
cp -r $PY3_PATH/${{ matrix.platform }}/release/lib/* build/output/python3.12
cp "$PY3_PATH/LICENSE.txt" build/output/python3.12
# Cleanup dev files
find build/output -type f \( -name "*.exp" -o -name "*.ilk" -o -name "*.lib" -o -name "*.pdb" \) -delete
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-build-${{ matrix.platform }}-${{ needs.setup.outputs.github_sha_short }}
path: build/output/
retention-days: 7
package:
needs: ["setup", "build"]
if: ${{ needs.setup.outputs.release_created }}
strategy:
matrix:
include:
- os: windows-latest
platform: win-64
- os: ubuntu-latest
platform: linux-64
- os: macos-latest
platform: osx-arm64
runs-on: ${{ matrix.os }}
outputs:
url: ${{ steps.release.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
conda
sparse-checkout-cone-mode: false
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-build-${{ matrix.platform }}-${{ needs.setup.outputs.github_sha_short }}
path: conda/
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: build-env
condarc: |
channels:
- conda-forge
create-args: >-
boa
init-shell: >-
bash
powershell
cache-downloads: true
cache-environment: true
- name: Prepare recipe
shell: bash -el {0}
run: |
# Replace version in meta.yaml
version="${{ needs.setup.outputs.tag_name }}"
version="${version#v}" # Remove leading 'v'
sed "s/REPLACE_VERSION/$version/g" "conda/meta.yaml.example" > "conda/meta.yaml"
# Ensure build.sh is executable on Unix systems
if [[ "$RUNNER_OS" == "Linux" ]] || [[ "$RUNNER_OS" == "macOS" ]]; then
chmod +x "conda/build.sh"
fi
- name: Build conda package
shell: bash -el {0}
run: |
set -e
# log (for debug)
conda env list
conda config --show channels
# build
conda mambabuild "conda" --output-folder conda-bld --no-test --channel conda-forge
- name: Prepare channel directory
shell: bash -el {0}
run: |
# Create repo directory
mkdir -p "build/package/${{ matrix.platform }}"
# Copy package files (.tar.bz2 or .conda)
find conda-bld -type f \( -name "*.tar.bz2" -o -name "*.conda" \) -exec cp {} "build/package/${{ matrix.platform }}/" \;
- name: Upload conda package artifact
uses: actions/upload-artifact@v4
with:
name: conda-package-${{ matrix.platform }}-${{ needs.setup.outputs.github_sha_short }}
path: build/package/${{ matrix.platform }}/
retention-days: 7
- name: Upload release asset
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v1
id: release
with:
tag_name: ${{ needs.setup.outputs.tag_name }}
files: |
build/package/${{ matrix.platform }}/*.tar.bz2
build/package/${{ matrix.platform }}/*.conda
repository:
needs: ["setup", "build", "package"]
if: ${{ needs.setup.outputs.release_created }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
- name: Install build tools
shell: bash -el {0}
run: |
conda install conda python
- name: Install conda-index
shell: bash -el {0}
run: |
python -m pip install conda-index
- name: Download aria2
if: ${{ !env.ACT && vars.DOWNLOAD_PACKAGES == 'true' }}
shell: bash -el {0}
run: sudo apt-get update && sudo apt-get install -y aria2
- name: Download packages from all releases
if: ${{ !env.ACT && vars.DOWNLOAD_PACKAGES == 'true' }}
shell: bash -el {0}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p build/repo/{linux-64,win-64,osx-arm64,noarch}
gh api /repos/${{ github.repository }}/releases?per_page=10 \
| jq -r '.[] | .assets[] | .browser_download_url' \
| grep -E "(\.tar\.bz2|\.conda)$" > urls.txt
# separate by platform
grep linux-64 urls.txt > linux.txt || true
grep win-64 urls.txt > win.txt || true
grep osx-arm64 urls.txt > osx.txt || true
grep -v -E "(linux-64|win-64)" urls.txt > noarch.txt || true
[ -s linux.txt ] && aria2c -x4 -s4 -j4 -i linux.txt -d build/repo/linux-64/ --continue
[ -s win.txt ] && aria2c -x4 -s4 -j4 -i win.txt -d build/repo/win-64/ --continue
[ -s osx.txt ] && aria2c -x4 -s4 -j4 -i osx.txt -d build/repo/osx-arm64/ --continue
[ -s noarch.txt ]&& aria2c -x4 -s4 -j4 -i noarch.txt -d build/repo/noarch/ --continue
- name: Download conda packages
uses: actions/download-artifact@v4
with:
pattern: conda-package-*
path: artifacts/
merge-multiple: false
- name: Organize conda packages
shell: bash -el {0}
run: |
# Move packages to correct structure
for dir in artifacts/conda-package-*; do
if [ -d "$dir" ]; then
platform=$(echo $dir | sed 's/.*conda-package-\(.*\)-.*/\1/')
mkdir -p build/repo/${platform}
mv $dir/* build/repo/${platform}/
rmdir $dir
fi
done
# Create noarch directory
mkdir -p build/repo/noarch
- name: Generate repodata
shell: bash -el {0}
run: |
python -m conda_index build/repo
- name: Create channel index.html
shell: bash -el {0}
run: |
cat > build/repo/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<title>Conda Channel - ${{ env.PROJECT_NAME }}</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; margin: 0; padding: 0; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }
.container { max-width: 900px; margin: 0 auto; padding: 40px 20px; }
.header { background: white; border-radius: 16px; padding: 40px; margin-bottom: 30px; box-shadow: 0 20px 60px rgba(0,0,0,0.1); }
h1 { color: #2d3748; margin: 0 0 10px 0; font-size: 2.5em; }
.subtitle { color: #718096; font-size: 1.2em; }
.card { background: white; border-radius: 12px; padding: 30px; margin-bottom: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
h2 { color: #4a5568; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
code { background: #f7fafc; padding: 3px 8px; border-radius: 4px; font-family: 'Monaco', 'Menlo', monospace; color: #e53e3e; }
pre { background: #2d3748; color: #e2e8f0; padding: 20px; border-radius: 8px; overflow-x: auto; line-height: 1.5; }
.platforms { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 20px; }
.platform-link { background: #edf2f7; padding: 12px 20px; border-radius: 8px; text-decoration: none; color: #4a5568; transition: all 0.3s; }
.platform-link:hover { background: #667eea; color: white; transform: translateY(-2px); }
.version-info { display: flex; gap: 20px; flex-wrap: wrap; }
.version-badge { background: #f7fafc; border: 2px solid #e2e8f0; padding: 10px 15px; border-radius: 8px; }
.icon { display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 8px; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>π¦ ${{ env.PROJECT_NAME }}</h1>
<div class="subtitle">Conda Channel for Python3 Language Module</div>
</div>
<div class="card">
<h2>π Quick Start</h2>
<p>Install directly using conda:</p>
<pre>conda install -c https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ ${{ env.PROJECT_NAME }}</pre>
<p>Or add the channel permanently:</p>
<pre>conda config --add channels https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ && conda install ${{ env.PROJECT_NAME }}</pre>
</div>
<div class="card">
<h2>π» Available Platforms</h2>
<div class="platforms">
<a href="linux-64/" class="platform-link">π§ Linux (64-bit)</a>
<a href="win-64/" class="platform-link">πͺ Windows (64-bit)</a>
<a href="osx-arm64/" class="platform-link">π macOS (ARM64)</a>
<a href="noarch/" class="platform-link">π¦ NoArch</a>
</div>
</div>
<div class="card">
<h2>π Latest Release</h2>
<div class="version-info">
<div class="version-badge">
<strong>Version:</strong> <code>${{ needs.setup.outputs.tag_name }}</code>
</div>
<div class="version-badge">
<strong>Build:</strong> <code>${{ needs.setup.outputs.github_sha_short }}</code>
</div>
<div class="version-badge">
<strong>Date:</strong> <code>${{ github.event.head_commit.timestamp }}</code>
</div>
</div>
</div>
<div class="card">
<h2>π Resources</h2>
<p>
<a href="https://github.com/${{ github.repository }}" style="color: #667eea;">GitHub Repository</a> β’
<a href="https://github.com/${{ github.repository }}/releases" style="color: #667eea;">Releases</a> β’
<a href="https://github.com/${{ github.repository }}/issues" style="color: #667eea;">Issues</a>
</p>
</div>
</div>
</body>
</html>
EOF
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: build/repo
- name: Deploy to GitHub Pages
if: ${{ !env.ACT }}
id: deployment
uses: actions/deploy-pages@v4
notify:
needs: ["setup", "build", "package", "repository"]
if: ${{ needs.setup.outputs.release_created && always() }}
runs-on: ubuntu-latest
steps:
- name: Send Discord Notification
if: ${{ needs.build.result == 'success' && needs.package.result == 'success' && needs.repository.result == 'success' }}
uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
embed-description: |
## <:plugin_creator:1336096248515657880> New Release: ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }}
### <:link:1342486300653129811> Downloads
-# <:curved_arrow_right:1342544469148565545> [${{ needs.setup.outputs.tag_name }}](${{ needs.package.outputs.url }})
### π Conda Channel
-# <:curved_arrow_right:1342544469148565545> https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/
<:blank:1335697913464098908>
**Install via conda:**
```bash
conda install -c https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ ${{ env.PROJECT_NAME }}
```
embed-color: 955135
- name: Send Failure Notification
if: ${{ needs.build.result == 'failure' || needs.package.result == 'failure' || needs.repository.result == 'failure' }}
uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
embed-description: |
## <a:cry:1247121995997384738> Release workflow failed for ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }}
embed-color: 16221227