Skip to content

ci: add multi-platform CMake build & release workflow #1

ci: add multi-platform CMake build & release workflow

ci: add multi-platform CMake build & release workflow #1

Workflow file for this run

name: Xary CI & Release Pipeline
on:
push:
branches: [ "main" ]
tags:
- 'v*' # Triggers automatic release when pushing tags like v0.1.0
pull_request:
branches: [ "main" ]
permissions:
contents: write
jobs:
# ---------------------------------------------------------------------------
# Job 1: Build & Verify across Windows, Linux, and macOS Matrix
# ---------------------------------------------------------------------------
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
artifact_name: xary-windows-x64.exe
binary_path: build/Release/xary.exe
- os: ubuntu-latest
artifact_name: xary-linux-x64
binary_path: build/xary
- os: macos-latest
artifact_name: xary-macos-x64
binary_path: build/xary
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: ⚙️ Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
- name: 🔨 Compile Binary
run: cmake --build build --config Release
- name: 🧪 Test CLI Binary Output
shell: bash
run: |
if [ "${{ runner.os }}" == "Windows" ]; then
./build/Release/xary.exe --version
./build/Release/xary.exe --help
else
./build/xary --version
./build/xary --help
fi
- name: 📦 Prepare Release Artifact
shell: bash
run: |
mkdir -p dist
cp ${{ matrix.binary_path }} dist/${{ matrix.artifact_name }}
- name: 📤 Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-build
path: dist/*
# ---------------------------------------------------------------------------
# Job 2: Automatically Create GitHub Release (Triggered on Version Tags)
# ---------------------------------------------------------------------------
release:
name: 🚀 Publish GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: 📥 Download All Compiled Artifacts
uses: actions/download-artifact@v4
- name: ⚡ Package Binary Assets
run: |
mkdir -p release_assets
cp windows-latest-build/xary-windows-x64.exe release_assets/
cp ubuntu-latest-build/xary-linux-x64 release_assets/
cp macos-latest-build/xary-macos-x64 release_assets/
- name: 📦 Publish Release to GitHub
uses: softprops/action-gh-release@v2
with:
files: release_assets/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}