Skip to content

Update build_and_release.yml #63

Update build_and_release.yml

Update build_and_release.yml #63

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- run: zig fmt --check .
build:
permissions: write-all
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
include:
- os: ubuntu-latest
target: x86_64-linux
- os: macos-latest
target: aarch64-macos-none
- os: windows-latest
target: x86_64-windows
runs-on: ${{ matrix.os }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Get commit hash
id: commit
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: goto-bus-stop/setup-zig@v2
name: Setup zig
with:
version: 0.13.0
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libx11-dev libgtk-4-dev build-essential
- name: Set SDKROOT (macOS)
if: matrix.os == 'macos-latest'
run: echo "export SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
- name: Get universal dependencies
run: zig fetch --save https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz
- name: Build binary
run: zig build -Doptimize=ReleaseSafe
- name: Rename binary (MacOS, Ubuntu)
if: matrix.os != 'windows-latest'
run: |
mv zig-out/bin/DiaB-concept zig-out/bin/DiaB-concept_${{ matrix.os }}-${{ matrix.target }}
chmod +x zig-out/bin/DiaB-concept_${{ matrix.os }}-${{ matrix.target }}
- name: Rename binary (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$binary = Get-ChildItem -Path zig-out\bin -Filter *.exe | Select-Object -First 1
if ($binary) {
$newName = "DiaB-concept_${{ matrix.os }}-${{ matrix.target }}.exe"
Rename-Item -Path $binary.FullName -NewName $newName
Write-Output "Renamed $($binary.Name) to $newName"
} else {
Write-Error "No .exe file found in zig-out\bin"
exit 1
}
- name: Release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
with:
tag_name: ${{ steps.commit.outputs.sha_short }}
name: Release ${{ steps.commit.outputs.sha_short }}
files: |
zig-out/bin/*
generate_release_notes: true