@@ -132,7 +132,7 @@ jobs:
132132 echo "version=$VERSION" >> $GITHUB_OUTPUT
133133 echo "Building version: $VERSION"
134134
135- - name : Package Release
135+ - name : Package Runtime Release
136136 run : |
137137 export PATH="$HOME/.local/bin:$PATH"
138138 VERSION=${{ steps.version.outputs.version }}
@@ -219,13 +219,109 @@ jobs:
219219
220220 echo ""
221221 echo "========================================="
222- echo "Package created: ${PACKAGE_NAME}.tar.gz"
222+ echo "Runtime package created: ${PACKAGE_NAME}.tar.gz"
223223 echo "========================================="
224224 ls -lh ${PACKAGE_NAME}.tar.gz
225225 echo ""
226226 echo "Contents:"
227227 tar -tzf ${PACKAGE_NAME}.tar.gz | head -30
228228
229+ - name : Package Development SDK
230+ run : |
231+ VERSION=${{ steps.version.outputs.version }}
232+ SDK_NAME="SwiftIR-SDK-${VERSION}-linux-x86_64"
233+
234+ echo "Creating development SDK package..."
235+ mkdir -p ${SDK_NAME}
236+
237+ # Copy the FULL swiftir-deps directory (headers, cmake configs, libraries)
238+ echo "Copying full dependencies..."
239+ cp -r /opt/swiftir-deps/* ${SDK_NAME}/
240+
241+ # Create setup script for SDK
242+ cat > ${SDK_NAME}/setup-sdk.sh << 'SDKEOF'
243+ #!/bin/bash
244+ # SwiftIR SDK Environment Setup
245+ # Source this file: source /path/to/SwiftIR-SDK/setup-sdk.sh
246+
247+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
248+
249+ export SWIFTIR_DEPS_DIR="$SCRIPT_DIR"
250+ export SWIFTIR_HOME="$SCRIPT_DIR"
251+ export LD_LIBRARY_PATH="$SCRIPT_DIR/lib:$LD_LIBRARY_PATH"
252+ export LIBRARY_PATH="$SCRIPT_DIR/lib:$LIBRARY_PATH"
253+ export CPATH="$SCRIPT_DIR/include:$CPATH"
254+ export PATH="$SCRIPT_DIR/bin:$PATH"
255+
256+ echo "SwiftIR SDK environment configured!"
257+ echo " SWIFTIR_DEPS_DIR=$SWIFTIR_DEPS_DIR"
258+ echo " LD_LIBRARY_PATH includes: $SCRIPT_DIR/lib"
259+ echo ""
260+ echo "You can now build SwiftIR with: swift build"
261+ SDKEOF
262+ chmod +x ${SDK_NAME}/setup-sdk.sh
263+
264+ # Create README for SDK
265+ cat > ${SDK_NAME}/README-SDK.md << 'READMEEOF'
266+ # SwiftIR Development SDK
267+
268+ This SDK contains everything needed to compile SwiftIR from source,
269+ including pre-built LLVM/MLIR, StableHLO, and XLA dependencies.
270+
271+ ## Quick Start (Google Colab / Linux)
272+
273+ 1. Extract and setup:
274+
275+ tar xzf SwiftIR-SDK-*-linux-x86_64.tar.gz
276+ cd SwiftIR-SDK-*
277+ source ./setup-sdk.sh
278+
279+ 2. Clone and build SwiftIR:
280+
281+ git clone https://github.com/pedronahum/SwiftIR.git
282+ cd SwiftIR
283+ swift build
284+
285+ 3. Run examples:
286+
287+ swift run RuntimeInfo
288+ swift run PJRT_Add_Example
289+
290+ ## Contents
291+
292+ - lib/ - Pre-built libraries (LLVM, MLIR, PJRT plugins, etc.)
293+ - include/ - Header files for compilation
294+ - lib/cmake/ - CMake configuration files
295+ - bin/ - LLVM/MLIR tools
296+
297+ ## Environment Variables
298+
299+ The setup-sdk.sh script sets:
300+ - SWIFTIR_DEPS_DIR - Points to this SDK directory
301+ - LD_LIBRARY_PATH - For runtime library loading
302+ - LIBRARY_PATH - For compile-time linking
303+ - CPATH - For header file discovery
304+
305+ ## Requirements
306+
307+ - Linux x86_64 (Ubuntu 22.04+ recommended)
308+ - Swift 6.0+ (development snapshot recommended)
309+ READMEEOF
310+
311+ # Create tarball
312+ tar -czvf ${SDK_NAME}.tar.gz ${SDK_NAME}/
313+
314+ echo ""
315+ echo "========================================="
316+ echo "SDK package created: ${SDK_NAME}.tar.gz"
317+ echo "========================================="
318+ ls -lh ${SDK_NAME}.tar.gz
319+ echo ""
320+ echo "SDK Contents summary:"
321+ echo " Libraries: $(find ${SDK_NAME}/lib -name '*.so' -o -name '*.a' 2>/dev/null | wc -l) files"
322+ echo " Headers: $(find ${SDK_NAME}/include -name '*.h' 2>/dev/null | wc -l) files"
323+ echo " CMake configs: $(find ${SDK_NAME}/lib/cmake -name '*.cmake' 2>/dev/null | wc -l) files"
324+
229325 - name : Create Package README
230326 run : |
231327 VERSION=${{ steps.version.outputs.version }}
@@ -297,18 +393,25 @@ jobs:
297393 rm ${PACKAGE_NAME}.tar.gz
298394 tar -czvf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}/
299395
300- - name : Upload Build Artifact
396+ - name : Upload Runtime Artifact
301397 uses : actions/upload-artifact@v4
302398 with :
303399 name : swiftir-linux-x86_64
304- path : SwiftIR-*-linux-x86_64.tar.gz
400+ path : SwiftIR-${{ steps.version.outputs.version }}-linux-x86_64.tar.gz
401+ retention-days : 14
402+
403+ - name : Upload SDK Artifact
404+ uses : actions/upload-artifact@v4
405+ with :
406+ name : swiftir-sdk-linux-x86_64
407+ path : SwiftIR-SDK-${{ steps.version.outputs.version }}-linux-x86_64.tar.gz
305408 retention-days : 14
306409
307410 # =============================================================
308- # Test the packaged release
411+ # Test the runtime package
309412 # =============================================================
310413 test-package :
311- name : Test Package (Ubuntu)
414+ name : Test Runtime Package (Ubuntu)
312415 needs : build-linux
313416 runs-on : ubuntu-24.04
314417
@@ -343,7 +446,7 @@ jobs:
343446 tar xzf SwiftIR-*-linux-x86_64.tar.gz
344447
345448 # Find the extracted directory (handles versioned names)
346- SWIFTIR_DIR=$(find . -maxdepth 1 -type d -name "SwiftIR-*" | head -1)
449+ SWIFTIR_DIR=$(find . -maxdepth 1 -type d -name "SwiftIR-*" -not -name "SwiftIR-SDK-*" | head -1)
347450 echo "Found SwiftIR directory: $SWIFTIR_DIR"
348451
349452 echo ""
@@ -368,12 +471,105 @@ jobs:
368471 exit 1
369472 fi
370473
474+ # =============================================================
475+ # Test the SDK package (can compile SwiftIR from source)
476+ # =============================================================
477+ test-sdk :
478+ name : Test SDK Package (Ubuntu)
479+ needs : build-linux
480+ runs-on : ubuntu-24.04
481+
482+ steps :
483+ - name : Checkout Repository
484+ uses : actions/checkout@v4
485+
486+ - name : Install System Dependencies
487+ run : |
488+ sudo apt-get update
489+ sudo apt-get install -y \
490+ build-essential cmake ninja-build git wget curl \
491+ clang-18 lld-18 \
492+ libc++-18-dev libc++abi-18-dev \
493+ libicu-dev libssl-dev libxml2-dev \
494+ libcurl4-openssl-dev libz-dev libzstd-dev \
495+ libncurses-dev zlib1g-dev
496+
497+ - name : Install Swift
498+ run : |
499+ SWIFT_URL="https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a-ubuntu22.04.tar.gz"
500+
501+ echo "Downloading Swift development snapshot..."
502+ curl -L "$SWIFT_URL" -o /tmp/swift.tar.gz
503+
504+ echo "Extracting Swift..."
505+ sudo mkdir -p /opt/swift
506+ sudo tar xzf /tmp/swift.tar.gz -C /opt/swift --strip-components=1
507+
508+ echo "Setting up PATH..."
509+ echo "/opt/swift/usr/bin" >> $GITHUB_PATH
510+ export PATH="/opt/swift/usr/bin:$PATH"
511+
512+ swift --version
513+
514+ - name : Download SDK Artifact
515+ uses : actions/download-artifact@v4
516+ with :
517+ name : swiftir-sdk-linux-x86_64
518+
519+ - name : Extract and Setup SDK
520+ run : |
521+ echo "Extracting SDK package..."
522+ tar xzf SwiftIR-SDK-*-linux-x86_64.tar.gz
523+
524+ # Find the extracted SDK directory
525+ SDK_DIR=$(find . -maxdepth 1 -type d -name "SwiftIR-SDK-*" | head -1)
526+ echo "Found SDK directory: $SDK_DIR"
527+
528+ echo ""
529+ echo "SDK contents:"
530+ ls -la "$SDK_DIR/"
531+
532+ echo ""
533+ echo "SDK libraries count: $(find $SDK_DIR/lib -name '*.so' -o -name '*.a' 2>/dev/null | wc -l)"
534+ echo "SDK headers count: $(find $SDK_DIR/include -name '*.h' 2>/dev/null | wc -l)"
535+ echo "CMake configs: $(find $SDK_DIR/lib/cmake -name '*.cmake' 2>/dev/null | wc -l)"
536+
537+ # Move SDK to /opt for consistent paths
538+ sudo mv "$SDK_DIR" /opt/swiftir-deps
539+ echo "SDK installed to /opt/swiftir-deps"
540+
541+ - name : Build SwiftIR from Source
542+ run : |
543+ # Setup environment
544+ export SWIFTIR_DEPS_DIR=/opt/swiftir-deps
545+ export LD_LIBRARY_PATH=/opt/swiftir-deps/lib:$LD_LIBRARY_PATH
546+ export LIBRARY_PATH=/opt/swiftir-deps/lib:$LIBRARY_PATH
547+ export CPATH=/opt/swiftir-deps/include:$CPATH
548+
549+ echo "Building SwiftIR..."
550+ swift build -c release
551+
552+ echo ""
553+ echo "Build successful!"
554+ ls -la .build/release/*.so 2>/dev/null || echo "No .so files (expected on some configs)"
555+
556+ - name : Run Example
557+ run : |
558+ export SWIFTIR_DEPS_DIR=/opt/swiftir-deps
559+ export LD_LIBRARY_PATH=/opt/swiftir-deps/lib:$LD_LIBRARY_PATH
560+
561+ echo "Running RuntimeInfo example..."
562+ swift run -c release RuntimeInfo 2>&1 | head -30 || true
563+
564+ echo ""
565+ echo "SDK test complete!"
566+
371567 # =============================================================
372568 # Create GitHub Release
373569 # =============================================================
374570 release :
375571 name : Create Release
376- needs : [build-linux, test-package]
572+ needs : [build-linux, test-package, test-sdk ]
377573 runs-on : ubuntu-latest
378574 if : startsWith(github.ref, 'refs/tags/')
379575
@@ -392,14 +588,23 @@ jobs:
392588 - name : Prepare Release Assets
393589 run : |
394590 mkdir release-assets
591+
592+ # Copy runtime package
395593 cp artifacts/swiftir-linux-x86_64/*.tar.gz release-assets/
396594
397- # Create a version-agnostic symlink name for "latest"
595+ # Copy SDK package
596+ cp artifacts/swiftir-sdk-linux-x86_64/*.tar.gz release-assets/
597+
598+ # Create version-agnostic names for "latest" downloads
398599 cd release-assets
399- for f in SwiftIR-*-linux-x86_64.tar.gz; do
400- cp "$f" SwiftIR-linux-x86_64.tar.gz
600+ for f in SwiftIR-[0-9]*-linux-x86_64.tar.gz; do
601+ [ -f "$f" ] && cp "$f" SwiftIR-linux-x86_64.tar.gz
602+ done
603+ for f in SwiftIR-SDK-*-linux-x86_64.tar.gz; do
604+ [ -f "$f" ] && cp "$f" SwiftIR-SDK-linux-x86_64.tar.gz
401605 done
402606
607+ echo "Release assets:"
403608 ls -la
404609
405610 - name : Create Release
@@ -414,52 +619,72 @@ jobs:
414619
415620 Swift for Intermediate Representation - Hardware-accelerated differentiable computing.
416621
417- ### Installation
622+ ### Download Options
418623
419- #### Google Colab (Recommended for TPU)
624+ | Package | Description | Size |
625+ |---------|-------------|------|
626+ | `SwiftIR-linux-x86_64.tar.gz` | Runtime only (pre-built binaries) | ~400MB |
627+ | `SwiftIR-SDK-linux-x86_64.tar.gz` | Full SDK (compile from source) | ~2GB |
420628
421- Download and extract in a Python cell:
629+ - **Runtime Package**: Use if you just want to run SwiftIR examples
630+ - **SDK Package**: Use if you want to compile SwiftIR from source (e.g., in Colab)
422631
423- !curl -L https://github.com/pedronahum/SwiftIR/releases/download/${{ github.ref_name }}/SwiftIR-linux-x86_64.tar.gz | tar xz -C /content
424- !mv /content/SwiftIR-* /content/SwiftIR
425- %env LD_LIBRARY_PATH=/content/SwiftIR/lib
426- %env SWIFTIR_HOME=/content/SwiftIR
632+ ### Google Colab Setup (Compile from Source)
427633
428- #### Local Linux Installation
634+ **Cell 1** - Install Swift:
429635
430- # Download
431- curl -LO https://github.com/pedronahum/SwiftIR/releases/download/${{ github.ref_name }}/SwiftIR-linux-x86_64.tar.gz
432- tar xzf SwiftIR-linux-x86_64.tar.gz
433- cd SwiftIR-*
636+ !curl -sL https://raw.githubusercontent.com/philipturner/swift-colab/refs/heads/main/install_swift_colab.sh | bash -s -- "11-28-a" &> /dev/null
637+ # Select Runtime > Change runtime type > Swift (if available) or restart
434638
435- # Quick setup
436- source ./setup.sh
639+ **Cell 2** - Download SDK and setup:
437640
438- # Or system-wide install
439- sudo ./install.sh
641+ !curl -L https://github.com/pedronahum/SwiftIR/releases/download/${{ github.ref_name }}/SwiftIR-SDK-linux-x86_64.tar.gz | tar xz -C /content
642+ !mv /content/SwiftIR-SDK-* /opt/swiftir-deps
643+ %env SWIFTIR_DEPS_DIR=/opt/swiftir-deps
644+ %env LD_LIBRARY_PATH=/opt/swiftir-deps/lib
645+ %env LIBRARY_PATH=/opt/swiftir-deps/lib
646+ %env CPATH=/opt/swiftir-deps/include
440647
441- ### What's Included
648+ **Cell 3** - Clone and build:
442649
443- - SwiftIR core libraries with automatic differentiation
444- - CPU PJRT plugin (bundled) - works out of the box
445- - Runtime detection for CPU/GPU/TPU
446- - Swift modules for development
650+ !git clone https://github.com/pedronahum/SwiftIR.git /content/SwiftIR
651+ !cd /content/SwiftIR && swift build
447652
448- ### Accelerator Support
653+ **Cell 4** - Run example:
449654
450- - CPU: Ready (plugin bundled)
451- - GPU: Install jax[cuda12] for CUDA plugin
452- - TPU: Ready on TPU VMs/Colab TPU
655+ !cd /content/SwiftIR && swift run RuntimeInfo
656+
657+ ### Local Linux Installation
658+
659+ # Download SDK
660+ curl -LO https://github.com/pedronahum/SwiftIR/releases/download/${{ github.ref_name }}/SwiftIR-SDK-linux-x86_64.tar.gz
661+ tar xzf SwiftIR-SDK-linux-x86_64.tar.gz
662+ cd SwiftIR-SDK-*
453663
454- ### Quick Test
664+ # Setup environment
665+ source ./setup-sdk.sh
455666
456- import SwiftIRRuntime
667+ # Clone and build SwiftIR
668+ git clone https://github.com/pedronahum/SwiftIR.git
669+ cd SwiftIR
670+ swift build
457671
458- // Detect available accelerators
459- RuntimeDetector.printInfo()
672+ # Run examples
673+ swift run RuntimeInfo
674+ swift run PJRT_Add_Example
460675
461- // Use auto-detected accelerator
462- let accelerator = RuntimeDetector.detect()
463- print("Best accelerator: \(accelerator)")
676+ ### What's Included in SDK
677+
678+ - Pre-built LLVM/MLIR libraries
679+ - Pre-built StableHLO libraries
680+ - Pre-built XLA/PJRT libraries
681+ - CPU PJRT plugin (bundled)
682+ - All headers and CMake configs
683+
684+ ### Accelerator Support
685+
686+ - CPU: Ready (plugin bundled)
687+ - GPU: Install jax[cuda12] for CUDA plugin
688+ - TPU: Ready on TPU VMs/Colab TPU
464689
465690 See the [full documentation](https://github.com/pedronahum/SwiftIR#readme) for more examples.
0 commit comments