zdxc/.github/workflows/build.yml

100 lines
2.8 KiB
YAML

name: Cross-platform builds
on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
concurrency:
group: builds-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.name }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- name: windows-x86_64
target: x86_64-windows-gnu
archive: zip
- name: linux-x86_64
target: x86_64-linux-gnu.2.28
archive: tar.gz
- name: macos-aarch64
target: aarch64-macos.13.0
archive: zip
steps:
- name: Check out source
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.17.0
- name: Build compiler, C library, and DXC drop-in
run: >-
zig build install dropin
-Doptimize=ReleaseFast
-Dtarget=${{ matrix.target }}
-Dcpu=baseline
--prefix zig-out/${{ matrix.name }}
- name: Package Linux build
if: matrix.archive == 'tar.gz'
run: >-
tar -czf zdxc-${{ matrix.name }}.tar.gz
-C zig-out/${{ matrix.name }} bin lib include
- name: Package Windows and macOS builds
if: matrix.archive == 'zip'
working-directory: zig-out/${{ matrix.name }}
run: zip -r ../../zdxc-${{ matrix.name }}.zip bin lib include
- name: Upload build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: zdxc-${{ matrix.name }}
path: zdxc-${{ matrix.name }}.${{ matrix.archive }}
if-no-files-found: error
retention-days: 14
release:
name: Publish release binaries
needs: build
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-rc')
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Download all platform bundles
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: zdxc-*
path: artifacts
merge-multiple: true
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" artifacts/*.tar.gz artifacts/*.zip --clobber
else
gh release create "$TAG" artifacts/*.tar.gz artifacts/*.zip \
--verify-tag --title "zdxc $TAG" --generate-notes
fi