Skip to content

Build Artifacts

Build Artifacts #80

Workflow file for this run

name: Build Artifacts
on:
workflow_run:
workflows: ["Test Suite"]
types: [completed]
branches: [main]
workflow_dispatch:
inputs:
platforms:
description: 'Platforms to build (comma-separated: linux,windows,macos)'
required: false
default: 'linux,windows,macos'
type: string
workflow_call: # Allow other workflows to call this one
permissions:
contents: write
packages: read
jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }}
strategy:
matrix:
include:
- os: linux
runner: ubuntu-latest
target: x86_64-linux
artifact: media-gen-linux-x86_64
- os: windows
runner: windows-2022 # Use specific version for better caching
target: x86_64-windows
artifact: media-gen-windows-x86_64.exe
- os: macos-intel
runner: macos-13
target: x86_64-macos
artifact: media-gen-macos-x86_64
- os: macos-arm
runner: macos-latest
target: aarch64-macos
artifact: media-gen-macos-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache FFmpeg binaries
uses: actions/cache@v4
continue-on-error: true # Don't fail if cache service is down
with:
path: src/vendor/ffmpeg
key: ffmpeg-binaries-${{ matrix.os }}-v1
restore-keys: |
ffmpeg-binaries-${{ matrix.os }}-
# Windows-specific: Cache PowerShell modules and temp directories
- name: Cache Windows build dependencies
if: matrix.os == 'windows'
uses: actions/cache@v4
continue-on-error: true # Don't fail if cache service is down
with:
path: |
~\AppData\Local\Temp\zig-*
~\AppData\Local\zig
key: windows-deps-${{ hashFiles('build.zig') }}
restore-keys: |
windows-deps-
- name: Setup Zig (with retry)
uses: mlugg/setup-zig@v2
with:
version: 0.15.1
# Retry setup if it fails due to network issues
continue-on-error: false
- name: Cache Zig build
uses: actions/cache@v4
continue-on-error: true # Don't fail if cache service is down
with:
path: |
.zig-cache
zig-out
key: zig-build-${{ matrix.os }}-${{ matrix.target }}-${{ hashFiles('build.zig', 'src/**/*.zig') }}
restore-keys: |
zig-build-${{ matrix.os }}-${{ matrix.target }}-
zig-build-${{ matrix.os }}-
# Windows-specific optimizations
- name: Configure Windows build environment
if: matrix.os == 'windows'
shell: pwsh
run: |
# Set Windows-specific environment variables for faster builds
echo "ZIG_GLOBAL_CACHE_DIR=$env:RUNNER_TEMP\zig-cache" >> $env:GITHUB_ENV
echo "ZIG_LOCAL_CACHE_DIR=.zig-cache" >> $env:GITHUB_ENV
# Use all available CPU cores
echo "ZIG_BUILD_JOBS=$env:NUMBER_OF_PROCESSORS" >> $env:GITHUB_ENV
- name: Build for ${{ matrix.target }} (Windows)
if: matrix.os == 'windows'
shell: pwsh
run: zig build -Dtarget=${{ matrix.target }} -Doptimize=ReleaseSafe
- name: Build for ${{ matrix.target }} (Unix)
if: matrix.os != 'windows'
shell: bash
run: zig build -Dtarget=${{ matrix.target }} -Doptimize=ReleaseSafe
- name: Copy artifact (Unix)
if: matrix.os != 'windows'
run: cp zig-out/bin/media-gen ${{ matrix.artifact }}
- name: Copy artifact (Windows)
if: matrix.os == 'windows'
shell: pwsh
run: |
Copy-Item "zig-out\bin\media-gen.exe" "${{ matrix.artifact }}" -Force
# Verify the file was created and get its size
$fileInfo = Get-Item "${{ matrix.artifact }}"
Write-Host "✅ Windows artifact created: $($fileInfo.Length) bytes"
- name: Upload artifact
uses: actions/upload-artifact@v4
continue-on-error: true # Don't fail if artifact service is down
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
retention-days: 30
# Fallback: Store artifact info if upload fails
- name: Store artifact info (fallback)
if: failure()
run: |
echo "Artifact upload failed, but build succeeded"
echo "Artifact: ${{ matrix.artifact }}"
if (Test-Path "${{ matrix.artifact }}") {
Get-Item "${{ matrix.artifact }}"
} else {
Write-Host "Artifact not found"
}
echo "Build completed successfully despite upload failure" >> build-status.txt
# Release job removed - use manual-release.yml workflow instead