Skip to content

Release Build Pipeline #25

Release Build Pipeline

Release Build Pipeline #25

Workflow file for this run

name: Release Build Pipeline
on:
release:
types: [published, created]
workflow_dispatch:
jobs:
build-native:
name: Build Native Library (${{ matrix.os }} - ${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-24.04
arch: x86_64
OUT_OS_NAME: linux
- os: ubuntu-24.04
arch: aarch64
OUT_OS_NAME: linux
- os: macos-15
arch: x86_64
OUT_OS_NAME: darwin
- os: macos-15
arch: arm64
OUT_OS_NAME: darwin
- os: windows-2025
arch: x86_64
OUT_OS_NAME: windows
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
# Add debug info for testing context
- name: Show Release Info
if: ${{ github.event_name == 'release' }}
run: |
echo "Release ID: ${{ github.event.release.id }}"
echo "Draft Status: ${{ github.event.release.draft }}"
echo "Tag: ${{ github.event.release.tag_name }}"
# Existing build steps remain unchanged
- name: Setup Julia
uses: julia-actions/setup-julia@v2
with:
version: '1.11'
arch: >-
${{
matrix.arch == 'x86_64' && 'x64' ||
matrix.arch == 'aarch64' && 'aarch64' ||
(matrix.arch == 'arm64' && startsWith(matrix.os, 'macos-')) && 'aarch64' ||
(matrix.arch == 'arm64') && 'x64' ||
'x64'
}}
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
# Install cross toolchain for aarch64 on Ubuntu
- name: Install cross toolchain (aarch64)
if: ${{ startsWith(matrix.os, 'ubuntu-') && matrix.arch == 'aarch64' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install dependencies
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install -y cmake swig gcc g++
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew update
brew install cmake swig
elif [[ "$RUNNER_OS" == "Windows" ]]; then
choco install cmake swig
fi
- name: Build native library
shell: bash
run: |
cd swig
if [[ "${{ matrix.os }}" == ubuntu-* && "${{ matrix.arch }}" == "aarch64" ]]; then
cmake -DJulia_PREFIX=$JULIA_DIR -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ .
elif [[ "${{ matrix.os }}" == macos-* && "${{ matrix.arch }}" == "x86_64" ]]; then
cmake -DJulia_PREFIX=$JULIA_DIR -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_SYSTEM_PROCESSOR=x86_64 .
elif [[ "${{ matrix.os }}" == macos-* && "${{ matrix.arch }}" == "arm64" ]]; then
cmake -DCMAKE_SYSTEM_PROCESSOR=aarch64 .
else
cmake -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} .
fi
cmake --build . --config Release
cmake --install . --config Release
cd ..
echo "Library built at: $(pwd)/src/main/resources/native/${{ matrix.OUT_OS_NAME }}/${{ matrix.arch }}"
# Add artifact retention period based on release type
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.OUT_OS_NAME }}-${{ matrix.arch }}
path: src/main/resources/native/${{ matrix.OUT_OS_NAME }}/${{ matrix.arch }}/
retention-days: ${{ github.event.release.draft && 7 || 1 }}
build-java:
name: Build Java Library
runs-on: ubuntu-24.04
needs: build-native
if: ${{ !cancelled() }} # Run unless previous jobs were cancelled
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Download native artifacts
uses: actions/download-artifact@v4
with:
path: native-artifacts
- name: Assemble native libraries
shell: bash
run: |
for artifact in native-artifacts/*; do
os_arch=$(basename $artifact)
os=$(echo $os_arch | cut -d'-' -f2)
arch=$(echo $os_arch | cut -d'-' -f3)
mkdir -p "src/main/resources/native/$os/$arch"
cp -R "$artifact"/* "src/main/resources/native/$os/$arch/"
done
echo "Assembled native libraries:"
find src/main/resources/native -type f
- name: Build Java library
run: ./gradlew build
# Test artifact before final upload
- name: Test JAR (Example)
run: |
# java -jar build/libs/*.jar --version
jar xf build/libs/*.jar META-INF/MANIFEST.MF
grep 'Implementation-Version' META-INF/MANIFEST.MF | awk -F ': ' '{print $2}'
# Conditional artifact upload
- name: Upload Java artifact
if: ${{ github.event.release.draft || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: java-library
path: build/libs/*.jar
retention-days: 7
# Only attach to release when published
- name: Attach to Release
if: ${{ github.event_name == 'release' && !github.event.release.draft }}
uses: softprops/action-gh-release@v2
with:
files: build/libs/*.jar