-
Notifications
You must be signed in to change notification settings - Fork 11
661 lines (541 loc) · 21.5 KB
/
julia-release.yml
File metadata and controls
661 lines (541 loc) · 21.5 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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
# Copyright 2025 The PECOS Developers
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
name: Julia Artifacts
env:
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
on:
push:
branches:
- main
- dev
- development
- master
tags:
- 'jl-*' # Trigger on Julia-specific tags
pull_request:
branches:
- main
- dev
- development
- master
workflow_dispatch:
inputs:
sha:
description: Commit SHA
type: string
dry_run:
description: 'Dry run (build but not publish)'
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
check_pr_push:
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' && github.event.action != 'closed' ||
github.event_name == 'push' && contains(fromJSON('["main", "master", "dev", "development"]'), github.ref_name) ||
github.event_name == 'push' && startsWith(github.ref, 'refs/tags/jl-')
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- name: Check if should run on PR push
id: check
run: |
# Always run on tag pushes (jl-* tags trigger releases)
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/jl-* ]]; then
echo "run=true" >> $GITHUB_OUTPUT
# Always run on pushes to main branches
elif [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref_name }}" =~ ^(main|master|dev|development)$ ]]; then
echo "run=true" >> $GITHUB_OUTPUT
# For PRs, check the TRIGGER_ON_PR_PUSH setting
elif [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ env.TRIGGER_ON_PR_PUSH }}" = "true" ]; then
echo "run=true" >> $GITHUB_OUTPUT
else
echo "run=false" >> $GITHUB_OUTPUT
fi
build_julia_binaries:
needs: check_pr_push
if: needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true'
runs-on: ${{ matrix.runner || matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
architecture: x86_64
- os: ubuntu-latest
architecture: aarch64
runner: ubuntu-latest
- os: macos-15-intel
architecture: x86_64
runner: macos-15-intel # Intel Mac for x86_64
- os: macos-latest
architecture: aarch64
runner: macos-latest # ARM64 Mac
- os: windows-latest
architecture: x86_64
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Rust
run: rustup show
- name: Install LLVM 14.0.6 using pecos-llvm (Unix)
if: runner.os != 'Windows'
run: |
echo "Installing LLVM using pecos..."
cargo run -p pecos-cli --release -- install llvm
echo "Setting LLVM environment variables..."
export PECOS_LLVM=$(cargo run -p pecos-cli --release -- llvm find 2>/dev/null)
export LLVM_SYS_140_PREFIX="$PECOS_LLVM"
echo "PECOS_LLVM=$PECOS_LLVM" >> $GITHUB_ENV
echo "LLVM_SYS_140_PREFIX=$LLVM_SYS_140_PREFIX" >> $GITHUB_ENV
echo "Verifying LLVM installation..."
cargo run -p pecos-cli --release -- llvm check
- name: Install LLVM 14.0.6 using pecos-llvm (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Write-Host "Installing LLVM using pecos..."
cargo run -p pecos-cli --release -- install llvm
Write-Host "Setting LLVM environment variables..."
$env:PECOS_LLVM = (cargo run -p pecos-cli --release -- llvm find 2>$null)
$env:LLVM_SYS_140_PREFIX = $env:PECOS_LLVM
"PECOS_LLVM=$env:PECOS_LLVM" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"LLVM_SYS_140_PREFIX=$env:LLVM_SYS_140_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Verifying LLVM installation..."
cargo run -p pecos-cli --release -- llvm check
- name: Install Rust target
run: |
# With native ARM64 runners, no cross-compilation setup is needed
# All builds are now native for their respective architectures
echo "Using native build for ${{ matrix.architecture }} on ${{ matrix.os }}"
- name: Set up Visual Studio environment on Windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Build library (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd julia/pecos-julia-ffi
cargo build --release
# Create artifact directory
New-Item -ItemType Directory -Force -Path ..\..\artifacts
# Copy the built library
Copy-Item ..\..\target\release\pecos_julia.dll -Destination ..\..\artifacts\
# List artifacts
Get-ChildItem ..\..\artifacts\
- name: Build library (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
cd julia/pecos-julia-ffi
# Set up build flags for macOS to avoid LLVM dependency issues
if [[ "${{ matrix.os }}" == macos-* ]]; then
# Prevent linking against LLVM's libunwind
export RUSTFLAGS="-C link-arg=-Wl,-dead_strip_dylibs -C link-arg=-Wl,-ld_classic"
# Remove LLVM from library paths during build
unset DYLD_LIBRARY_PATH
unset DYLD_FALLBACK_LIBRARY_PATH
# Explicitly exclude LLVM libraries from linking
export RUSTFLAGS="$RUSTFLAGS -L native=/usr/lib"
fi
# Native build for all platforms (no cross-compilation needed with native ARM64 runners)
cargo build --release
target_dir="../../target/release"
# Create artifact directory
mkdir -p ../../artifacts
# Copy the built library
if [[ "${{ matrix.os }}" == macos-* ]]; then
cp $target_dir/libpecos_julia.dylib ../../artifacts/
# Fix any remaining LLVM dependencies
echo "Checking and fixing library dependencies..."
otool -L ../../artifacts/libpecos_julia.dylib
# Check for any problematic dependencies
if otool -L ../../artifacts/libpecos_julia.dylib | grep -q "/tmp/llvm"; then
echo "ERROR: Binary has dependencies on /tmp/llvm which won't exist at runtime!"
echo "Attempting to fix..."
# For libunwind specifically, we'll strip it out by creating a new dylib without it
if otool -L ../../artifacts/libpecos_julia.dylib | grep -q "/tmp/llvm/lib/libunwind.dylib"; then
echo "Creating fixed library without LLVM libunwind dependency..."
# Use install_name_tool to remove the dependency by setting it to a weak import
# that can fail at runtime without crashing
install_name_tool -change /tmp/llvm/lib/libunwind.dylib /usr/lib/libSystem.B.dylib ../../artifacts/libpecos_julia.dylib || \
echo "Warning: Could not remap libunwind dependency"
fi
fi
echo "Final library dependencies:"
otool -L ../../artifacts/libpecos_julia.dylib
else
cp $target_dir/libpecos_julia.so ../../artifacts/
fi
# List artifacts
ls -la ../../artifacts/
- name: Create tarball
run: |
cd artifacts
mkdir -p lib
mv * lib/ 2>/dev/null || true
tar -czf ../pecos_julia-${{ matrix.os }}-${{ matrix.architecture }}.tar.gz lib
cd ..
ls -la *.tar.gz
- name: Upload binary
uses: actions/upload-artifact@v7
with:
name: julia-binary-${{ matrix.os }}-${{ matrix.architecture }}
path: pecos_julia-*.tar.gz
test_binaries:
needs: build_julia_binaries
if: |
always() &&
needs.build_julia_binaries.result == 'success'
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
julia-version: ['1.10', '1'] # 1.10 = LTS, 1 = latest stable
platform:
- runner: ubuntu-latest
os: ubuntu-latest
architecture: x86_64
- runner: windows-latest
os: windows-latest
architecture: x86_64
- runner: macos-15-intel
os: macos-15-intel
architecture: x86_64
- runner: macos-latest
os: macos-latest
architecture: aarch64
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Julia ${{ matrix.julia-version }}
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: Download binary
uses: actions/download-artifact@v7
with:
name: julia-binary-${{ matrix.platform.os }}-${{ matrix.platform.architecture }}
path: ./julia-binary
- name: Set up test environment
run: |
# Extract the tarball
cd julia-binary
tar -xzf *.tar.gz
cd ..
# Create a temporary JLL structure
mkdir -p temp_jll
cp -r julia-binary/lib temp_jll/
cd julia/PECOS.jl
# Create a test script that uses the binary directly
cat > test_binary.jl << 'EOF'
# Add the library path
lib_path = joinpath(@__DIR__, "..", "..", "temp_jll", "lib")
# Determine the library name based on OS
lib_name = if Sys.iswindows()
"pecos_julia.dll"
elseif Sys.isapple()
"libpecos_julia.dylib"
else
"libpecos_julia.so"
end
lib_file = joinpath(lib_path, lib_name)
# Test direct ccall
println("Testing binary at: $lib_file")
# Test version function
ptr = ccall((:pecos_version, lib_file), Ptr{UInt8}, ())
version = unsafe_string(ptr)
ccall((:free_rust_string, lib_file), Cvoid, (Ptr{UInt8},), ptr)
println("Version: $version")
# Test add function
result = ccall((:add_two_numbers, lib_file), Int64, (Int64, Int64), 10, 32)
println("10 + 32 = $result")
if result == 42
println("Binary test passed!")
exit(0)
else
println("Binary test failed!")
exit(1)
end
EOF
- name: Test binary with Julia ${{ matrix.julia-version }}
run: |
cd julia/PECOS.jl
julia test_binary.jl
create_jll_package:
needs: [build_julia_binaries, test_binaries]
if: |
needs.build_julia_binaries.result == 'success' &&
needs.test_binaries.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Julia
uses: julia-actions/setup-julia@v2
with:
version: '1.10'
- name: Create distribution directories
run: |
mkdir -p dist/binaries
mkdir -p dist/jll
# Download artifacts into temp directory first
- name: Download all binaries
uses: actions/download-artifact@v7
with:
path: temp-artifacts/
- name: Organize binaries
run: |
# Move all binaries to distribution directory
for artifact in temp-artifacts/julia-binary-*/; do
if [ -d "$artifact" ]; then
echo "Processing $artifact"
cp "$artifact"* dist/binaries/
fi
done
# List collected binaries
echo "=== Collected binaries ==="
ls -la dist/binaries/
- name: Create JLL structure
run: |
cd julia/PECOS.jl
# Create a script to generate JLL package structure
cat > create_jll.jl << 'EOF'
version = "0.1.0"
# Create JLL directory structure
jll_dir = joinpath(@__DIR__, "..", "..", "dist", "jll", "PECOS_julia_jll")
mkpath(joinpath(jll_dir, "src"))
# Create Project.toml
project_content = """
name = "PECOS_julia_jll"
uuid = "00000000-0000-0000-0000-000000000000" # Will be assigned by registry
version = "$version+0"
[deps]
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[compat]
JLLWrappers = "1.6"
julia = "1.10"
"""
write(joinpath(jll_dir, "Project.toml"), project_content)
# Create basic JLL wrapper
jll_content = """
module PECOS_julia_jll
using Libdl
const libpecos_julia = "libpecos_julia"
function __init__()
# Initialization code will be added by BinaryBuilder
end
end # module
"""
write(joinpath(jll_dir, "src", "PECOS_julia_jll.jl"), jll_content)
println("Created JLL structure at: $jll_dir")
EOF
julia create_jll.jl
- name: Create release info
run: |
cat > dist/RELEASE_INFO.md << 'EOF'
# PECOS Julia Binary Distribution
This distribution contains:
1. **binaries/** - Pre-built libraries for all platforms
- Linux x86_64: libpecos_julia.so
- Linux aarch64: libpecos_julia.so
- macOS x86_64: libpecos_julia.dylib
- macOS aarch64: libpecos_julia.dylib
- Windows x86_64: pecos_julia.dll
2. **jll/** - JLL package structure (for BinaryBuilder submission)
## Next Steps
1. Submit to Yggdrasil for JLL creation
2. Wait for JLL registration
3. Update PECOS.jl to use registered JLL
4. Register PECOS.jl package
## Version
Version: 0.1.0
Commit: ${{ github.sha }}
EOF
- name: Upload distribution bundle
uses: actions/upload-artifact@v7
with:
name: pecos-julia-distribution
path: dist/
create_release_bundle:
needs: [build_julia_binaries, test_binaries]
if: |
needs.build_julia_binaries.result == 'success' &&
needs.test_binaries.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.sha || github.sha }}
- name: Create distribution directories
run: |
mkdir -p release-bundle/binaries
mkdir -p release-bundle/checksums
# Download artifacts
- name: Download all binaries
uses: actions/download-artifact@v7
with:
path: temp-artifacts/
- name: Organize and checksum binaries
run: |
# Process each platform's binary
for artifact in temp-artifacts/julia-binary-*/; do
if [ -d "$artifact" ]; then
platform=$(basename "$artifact" | sed 's/julia-binary-//')
echo "Processing $platform"
# Move the tarball
mv "$artifact"/*.tar.gz "release-bundle/binaries/" || true
# Create checksum
cd release-bundle/binaries
for tarball in pecos_julia-*.tar.gz; do
if [ -f "$tarball" ]; then
sha256sum "$tarball" > "../checksums/${tarball}.sha256"
fi
done
cd ../..
fi
done
# List final structure
echo "=== Release Bundle Structure ==="
find release-bundle -type f | sort
- name: Generate Artifacts.toml
run: |
cd release-bundle
# Create Artifacts.toml with actual checksums
cat > ../julia/PECOS.jl/Artifacts.toml << 'EOF'
# Auto-generated by julia-release workflow
# For release: ${{ github.ref_name }}
[PECOS_julia]
git-tree-sha1 = "0000000000000000000000000000000000000000" # Tree hash will be computed on first use
EOF
# Add download entries for each platform
for tarball in binaries/*.tar.gz; do
if [ -f "$tarball" ]; then
filename=$(basename "$tarball")
platform=$(echo "$filename" | sed 's/pecos_julia-//; s/.tar.gz//')
sha256=$(sha256sum "$tarball" | cut -d' ' -f1)
cat >> ../julia/PECOS.jl/Artifacts.toml << EOF
[[PECOS_julia.download]]
url = "https://github.com/PECOS-packages/PECOS/releases/download/${{ github.ref_name }}/$filename"
sha256 = "$sha256"
EOF
fi
done
echo "Generated Artifacts.toml:"
cat ../julia/PECOS.jl/Artifacts.toml
- name: Create submission instructions
run: |
cat > release-bundle/SUBMISSION_INSTRUCTIONS.md << 'EOF'
# Julia Package Submission Instructions
This bundle contains pre-built binaries for PECOS.jl.
## Contents
- `binaries/` - Pre-built libraries for all platforms
- `checksums/` - SHA256 checksums for verification
## Manual Submission Process
### Option 1: Submit to Julia General Registry (Recommended)
1. Update `julia/PECOS.jl/deps/Artifacts.toml`:
- Add the URLs where you'll host these binaries
- Add the SHA256 checksums from the checksums folder
2. Host the binaries:
- Create a GitHub release and upload the tarballs
- Or use any other hosting service
3. Register the package:
```julia
using Registrator
Registrator.register(
"https://github.com/PECOS-packages/PECOS.git",
subdir="julia/PECOS.jl"
)
```
### Option 2: Submit to Yggdrasil (For JLL creation)
1. Fork https://github.com/JuliaPackaging/Yggdrasil
2. Create a new folder: `P/PECOS_julia/`
3. Copy `build_tarballs.jl` from the PECOS repo
4. Create a pull request
## Platform Support
Binaries are included for:
- Linux x86_64
- Linux aarch64
- macOS x86_64
- macOS aarch64
- Windows x86_64
## Version Info
- Version: 0.1.0
- Commit: ${{ github.sha }}
- Branch: ${{ github.ref_name }}
- Date: $(date -u +%Y-%m-%d)
EOF
- name: Create tarball of entire bundle
run: |
tar -czf pecos-julia-release-bundle-${{ github.run_number }}.tar.gz release-bundle/
ls -lh pecos-julia-release-bundle-*.tar.gz
- name: Upload release bundle
uses: actions/upload-artifact@v7
with:
name: pecos-julia-release-bundle
path: pecos-julia-release-bundle-*.tar.gz
retention-days: 30 # Keep for 30 days
- name: Determine if pre-release
id: check-prerelease
if: startsWith(github.ref, 'refs/tags/jl-')
run: |
# Extract version from tag (remove jl- prefix)
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#jl-}"
# Check if it contains a hyphen (pre-release indicator)
if [[ "$VERSION" == *"-"* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "Pre-release detected: $VERSION"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "Release version detected: $VERSION"
fi
- name: Create GitHub Release and Upload Binaries
if: startsWith(github.ref, 'refs/tags/jl-')
uses: softprops/action-gh-release@v2
with:
files: release-bundle/binaries/*.tar.gz
body: |
## Julia binaries for PECOS ${{ github.ref_name }}
These binaries are automatically downloaded when installing the Julia package.
### Installation
```julia
using Pkg
Pkg.add(url="https://github.com/PECOS-packages/PECOS", subdir="julia/PECOS.jl")
```
The correct binary for your platform will be downloaded automatically.
draft: false
prerelease: ${{ steps.check-prerelease.outputs.is_prerelease }}
fail_on_unmatched_files: true
- name: Commit Artifacts.toml to branch
if: startsWith(github.ref, 'refs/tags/jl-')
run: |
# Configure git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Add and commit the Artifacts.toml
git add julia/PECOS.jl/Artifacts.toml
git commit -m "Add Artifacts.toml for ${{ github.ref_name }}" || echo "No changes to commit"
# Push to the tag's branch
git push origin HEAD:${{ github.ref_name }}-artifacts || echo "Push failed"