Fix ci. #496
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Latest Build | |
on: | |
workflow_dispatch: | |
inputs: | |
deps_rev_override: | |
description: 'Deps Revision Override' | |
type: string | |
default: '' | |
required: false | |
push: | |
branches: | |
- master | |
paths: | |
- '**' | |
- '!.github/**' | |
- '!**.md' | |
- '!.gitattributes' | |
- '!examples/**.cy' | |
- '!examples/**/*.cy' | |
# Cancel previous job if it's running. | |
concurrency: | |
group: latest | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: host=${{ matrix.config.host }} cmd=${{ matrix.config.cmd }} target=${{ matrix.config.target }} mode=${{ matrix.config.mode }} | |
runs-on: ${{ matrix.config.host }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- host: ubuntu-22.04 | |
target: x86_64-linux-gnu | |
mode: release | |
cmd: cli | |
- host: ubuntu-22.04 | |
target: x86_64-selinux-gnu | |
mode: release | |
cmd: cli | |
- host: macos-12 | |
target: x86_64-macos-none | |
mode: release | |
cmd: cli | |
- host: macos-14 | |
target: aarch64-macos-none | |
mode: release | |
cmd: cli | |
- host: windows-2022 | |
target: x86_64-windows-gnu | |
mode: release | |
cmd: cli | |
- host: windows-2022 | |
target: x86_64-windows-gnu | |
mode: release | |
cmd: lib | |
- host: windows-2022 | |
target: x86_64-windows-msvc | |
mode: release | |
cmd: lib | |
- host: ubuntu-22.04 | |
target: wasm32-freestanding | |
mode: release | |
cmd: web-lib | |
- host: ubuntu-22.04 | |
target: wasm32-wasi | |
mode: release | |
cmd: cli | |
- host: ubuntu-22.04 | |
target: x86_64-linux-gnu | |
mode: release | |
cmd: lib | |
- host: macos-12 | |
target: x86_64-macos-none | |
mode: release | |
cmd: lib | |
- host: macos-14 | |
target: aarch64-macos-none | |
mode: release | |
cmd: lib | |
env: | |
BIN_ZIP: >- | |
${{ fromJson('{ | |
"x86_64-windows-gnu": "cyber-windows-x64.zip", | |
"x86_64-linux-gnu": "cyber-linux-x64.tar.gz", | |
"x86_64-selinux-gnu": "cyber-selinux-x64.tar.gz", | |
"x86_64-macos-none": "cyber-macos-x64.tar.gz", | |
"aarch64-macos-none": "cyber-macos-arm64.tar.gz", | |
"wasm32-freestanding": "cyber-web.wasm", | |
"wasm32-wasi": "cyber-wasi.wasm", | |
}')[matrix.config.target] }} | |
ZIG_TARGET_FLAG: >- | |
${{ fromJson('{ | |
"x86_64-windows-gnu": "-Dtarget=x86_64-windows-gnu -Dcpu=baseline", | |
"x86_64-windows-msvc": "-Dtarget=x86_64-windows-msvc -Dcpu=baseline", | |
"x86_64-linux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline", | |
"x86_64-selinux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline -Dselinux", | |
"x86_64-macos-none": "-Dtarget=x86_64-macos-none -Dcpu=baseline", | |
"aarch64-macos-none": "-Dtarget=aarch64-macos-none -Dcpu=baseline", | |
"wasm32-freestanding": "-Dtarget=wasm32-freestanding", | |
"wasm32-wasi": "-Dtarget=wasm32-wasi", | |
}')[matrix.config.target] }} | |
BUILD_HOST: ${{ matrix.config.host }} | |
BUILD_TARGET: ${{ matrix.config.target }} | |
BUILD_MODE: ${{ matrix.config.mode }} | |
BUILD_CMD: ${{ matrix.config.cmd }} | |
BIN_NAME: cyber | |
BIN_EXT: ${{ contains(matrix.config.target, 'windows') && '.exe' || '' }} | |
ZIG_MODE_FLAG: ${{ (matrix.config.mode == 'release' && '-Doptimize=ReleaseFast') || '' }} | |
DEV_FLAG: ${{ startsWith(github.ref, 'refs/tags/') && '-Ddev=false' || '' }} | |
ZIG_VERSION: 0.12.0 | |
steps: | |
- name: Install Linux deps. | |
if: env.BUILD_HOST == 'ubuntu-22.04' && env.BUILD_TARGET == 'x86_64-linux-gnu' | |
run: | | |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" | |
sudo apt-get update -y -qq | |
sudo apt-get install xz-utils | |
- name: Clone repo. | |
uses: actions/checkout@v2 | |
with: | |
# Fetch all so commit count can be computed from tag. | |
fetch-depth: 0 | |
#submodules: recursive | |
- name: Install zig. | |
if: env.BUILD_HOST == 'ubuntu-22.04' | |
run: | | |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin | |
- name: Install wasm3. | |
if: env.BUILD_HOST == 'ubuntu-22.04' && (env.BUILD_TARGET == 'wasm32-freestanding' || env.BUILD_TARGET == 'wasm32-wasi') | |
run: | | |
git clone --depth=1 https://github.com/wasm3/wasm3.git | |
cd wasm3 | |
mkdir build | |
cd build | |
cmake .. | |
make | |
- name: Install zig. | |
if: env.BUILD_HOST == 'macos-12' | |
run: | | |
wget -c https://ziglang.org/builds/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin | |
xcode-select --print-path | |
- name: Install zig. | |
if: env.BUILD_HOST == 'macos-14' | |
run: | | |
wget -c https://ziglang.org/builds/zig-macos-aarch64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin | |
xcode-select --print-path | |
- name: Install zig. | |
if: env.BUILD_HOST == 'windows-2022' | |
run: | | |
Invoke-WebRequest -Uri 'https://ziglang.org/builds/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip' | |
cd C:\ | |
7z x zig.zip | |
Add-Content $env:GITHUB_PATH 'C:\zig-windows-x86_64-${{ env.ZIG_VERSION }}\' | |
- name: Setup script. | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
async function execCmd(name, args) { | |
const opts = {}; | |
let out = ''; | |
let err = ''; | |
opts.listeners = { | |
stdout: (data) => { | |
out += data.toString(); | |
}, | |
stderr: (data) => { | |
process.stderr.write(data.toString()); | |
} | |
}; | |
// opt.cwd = './lib'; | |
await exec.exec(name, args, opts); | |
return out; | |
} | |
const version = await execCmd('zig', ['build', 'version']); | |
const parts = version.split('.') | |
const last_version = parts[0] + '.' + (parseInt(parts[1])-1) | |
core.exportVariable('SHORT_VERSION', version); | |
await execCmd('git', ['fetch', '--all', '--tags']); | |
const build = await execCmd('git', ['rev-list', '--count', `${last_version}..${context.sha}`]) | |
core.exportVariable('BUILD', build.trim()); | |
core.exportVariable('COMMIT', context.sha.substring(0, 7)); | |
- name: Cache. | |
#if: env.BUILD_TARGET != 'x86_64-windows-gnu' | |
uses: actions/cache@v2 | |
with: | |
path: |- | |
~/.cache/zig | |
zig-cache | |
~/AppData/Local/zig | |
key: | |
build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1 | |
restore-keys: | |
build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1 | |
- name: Run tests. (debug) | |
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc')) | |
run: | | |
zig build test ${{ env.ZIG_TARGET_FLAG }} ${{ env.DEV_FLAG }} | |
# Optimize with ReleaseSafe since there are issues with Zig 0.11.0 and building tests for ReleaseFast. | |
- name: Run tests. (release) | |
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc')) | |
run: | | |
zig build test ${{ env.ZIG_TARGET_FLAG }} ${{ env.DEV_FLAG}} -Doptimize=ReleaseFast | |
- name: Run tests. | |
if: env.BUILD_TARGET == 'wasm32-freestanding' || env.BUILD_TARGET == 'wasm32-wasi' | |
run: | | |
zig build build-test -Dtarget=wasm32-wasi ${{ env.ZIG_MODE_FLAG }} ${{ env.DEV_FLAG }} | |
wasm3/build/wasm3 zig-out/bin/unit_test.wasm | |
wasm3/build/wasm3 zig-out/bin/test.wasm | |
wasm3/build/wasm3 zig-out/bin/trace_test.wasm | |
- name: Build. | |
run: zig build ${{ env.BUILD_CMD }} ${{ env.ZIG_MODE_FLAG }} ${{ env.ZIG_TARGET_FLAG }} ${{ env.DEV_FLAG }} | |
# Remove when zig strip is fixed. | |
- name: Strip (Linux) | |
if: env.BUILD_TARGET == 'x86_64-linux-gnu' && env.BUILD_MODE == 'release' && env.BUILD_CMD == 'cli' | |
run: | | |
strip zig-out/bin/cyber | |
# # Don't strip aarch64 since it was already code signed. | |
# # TODO: Look for way to make zig strip before doing the codesign. | |
# - name: Strip (macOS) | |
# if: env.BUILD_TARGET == 'x86_64-macos-none' && env.BUILD_MODE == 'release' | |
# run: | | |
# strip zig-out/${{ env.BUILD_TARGET }}/main/main | |
# # Currently just ad hoc signing. | |
# # aarch64 build is automatically signed by zig. | |
# - name: Codesign (macOS) | |
# if: env.BUILD_TARGET == 'x86_64-macos-none' && env.BUILD_MODE == 'release' | |
# run: | | |
# codesign --force --deep -s - zig-out/${{ env.BUILD_TARGET }}/main/main | |
# - name: Copy binary. | |
# run: cp | |
# zig-out/${{ env.BUILD_TARGET }}/main/main${{ env.BIN_EXT }} | |
# zig-out/${{ env.BUILD_TARGET }}/main/cosmic${{ env.BIN_EXT }} | |
- name: Zip. (linux/macos) | |
if: (env.BUILD_HOST == 'ubuntu-22.04' || env.BUILD_HOST == 'macos-12' || env.BUILD_HOST == 'macos-14') && env.BUILD_TARGET != 'wasm32-wasi' && env.BUILD_CMD == 'cli' | |
run: | | |
tar -C zig-out/bin -czvf ${{ env.BIN_ZIP }} cyber | |
- name: Zip. (windows) | |
if: env.BUILD_TARGET == 'x86_64-windows-gnu' && env.BUILD_CMD == 'cli' | |
shell: bash | |
run: | | |
cd zig-out/bin && 7z a ../../${{env.BIN_ZIP}} cyber.exe | |
- name: Move. (windows lib) | |
if: env.BUILD_TARGET == 'x86_64-windows-gnu' && env.BUILD_CMD == 'lib' | |
run: | | |
mv zig-out/lib/cyber.lib libcyber-windows-gnu-x64.lib | |
- name: Move. (windows lib) | |
if: env.BUILD_TARGET == 'x86_64-windows-msvc' && env.BUILD_CMD == 'lib' | |
run: | | |
mv zig-out/lib/cyber.lib libcyber-windows-msvc-x64.lib | |
- name: Move. (linux lib) | |
if: env.BUILD_TARGET == 'x86_64-linux-gnu' && env.BUILD_CMD == 'lib' | |
run: | | |
mv zig-out/lib/libcyber.a libcyber-linux-x64.a | |
- name: Move. (macos lib) | |
if: env.BUILD_TARGET == 'x86_64-macos-none' && env.BUILD_CMD == 'lib' | |
run: | | |
mv zig-out/lib/libcyber.a libcyber-macos-x64.a | |
- name: Move. (macos lib) | |
if: env.BUILD_TARGET == 'aarch64-macos-none' && env.BUILD_CMD == 'lib' | |
run: | | |
mv zig-out/lib/libcyber.a libcyber-macos-arm64.a | |
- name: Move. (wasm) | |
if: env.BUILD_TARGET == 'wasm32-freestanding' | |
run: | | |
mv zig-out/bin/cyber-web.wasm ${{ env.BIN_ZIP }} | |
- name: Move. (wasi) | |
if: env.BUILD_TARGET == 'wasm32-wasi' | |
run: | | |
mv zig-out/bin/cyber.wasm ${{ env.BIN_ZIP }} | |
- name: Save artifact. | |
if: env.BUILD_CMD == 'cli' || env.BUILD_CMD == 'web-lib' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bin | |
path: | | |
${{ env.BIN_ZIP }} | |
- name: Save artifact. | |
if: env.BUILD_CMD == 'lib' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bin | |
path: | | |
libcyber-windows-gnu-x64.lib | |
libcyber-windows-msvc-x64.lib | |
libcyber-linux-x64.a | |
libcyber-macos-x64.a | |
libcyber-macos-arm64.a | |
cyber-web.wasm | |
outputs: | |
short_version: ${{ env.SHORT_VERSION }} | |
# version: ${{ env.BUILD_VERSION }} | |
docs: | |
runs-on: ubuntu-22.04 | |
env: | |
ZIG_VERSION: 0.12.0 | |
steps: | |
- name: Clone repo. | |
uses: actions/checkout@v3 | |
with: | |
submodules: false | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: Install zig. | |
run: | | |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin | |
- name: Build md4c. | |
run: | | |
git clone --depth=1 https://github.com/mity/md4c.git | |
cd md4c | |
mkdir build | |
cd build | |
cmake .. | |
make | |
- name: Setup script. | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
async function execCmd(name, args) { | |
const opts = {}; | |
let out = ''; | |
let err = ''; | |
opts.listeners = { | |
stdout: (data) => { | |
out += data.toString(); | |
}, | |
stderr: (data) => { | |
process.stderr.write(data.toString()); | |
} | |
}; | |
// opt.cwd = './lib'; | |
await exec.exec(name, args, opts); | |
return out; | |
} | |
const version = await execCmd('zig', ['build', 'version']); | |
const parts = version.split('.') | |
const last_version = parts[0] + '.' + (parseInt(parts[1])-1) | |
core.exportVariable('SHORT_VERSION', version); | |
await execCmd('git', ['fetch', '--all', '--tags']); | |
const build = await execCmd('git', ['rev-list', '--count', `${last_version}..${context.sha}`]) | |
core.exportVariable('BUILD', build.trim()); | |
core.exportVariable('COMMIT', context.sha.substring(0, 7)); | |
- name: Cache. | |
uses: actions/cache@v2 | |
with: | |
path: |- | |
~/.cache/zig | |
zig-cache | |
key: | |
build-1 | |
restore-keys: | |
build-1 | |
- name: Build Cyber. | |
run: zig build cli | |
- name: Generate docs. (Release) | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
LD_LIBRARY_PATH=`pwd`/md4c/build/src zig-out/bin/cyber docs/gen-docs.cy -version v${{ env.SHORT_VERSION }} | |
mv docs/docs-modules.md docs.md | |
mv docs/docs.html docs.html | |
- name: Generate docs. (Dev) | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
run: | | |
LD_LIBRARY_PATH=`pwd`/md4c/build/src zig-out/bin/cyber docs/gen-docs.cy -version "${{ format('v{0}-DEV {1}-{2}', env.SHORT_VERSION, env.BUILD, env.COMMIT) }}" | |
mv docs/docs-modules.md docs.md | |
mv docs/docs.html docs.html | |
- name: Save artifact. | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bin | |
path: | | |
docs.html | |
docs.md | |
release: | |
needs: [build, docs] | |
name: Release | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: bin | |
# Manual dispatch. | |
- name: Github Latest Release. | |
uses: marvinpinto/action-automatic-releases@latest | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
automatic_release_tag: latest | |
prerelease: false | |
title: v${{ needs.build.outputs.short_version }}-DEV | |
files: | | |
cyber-linux-x64.tar.gz | |
cyber-selinux-x64.tar.gz | |
cyber-macos-x64.tar.gz | |
cyber-macos-arm64.tar.gz | |
cyber-windows-x64.zip | |
libcyber-windows-gnu-x64.lib | |
libcyber-windows-msvc-x64.lib | |
libcyber-linux-x64.a | |
libcyber-macos-x64.a | |
libcyber-macos-arm64.a | |
cyber-web.wasm | |
cyber-wasi.wasm | |
docs.html | |
docs.md | |
# Auto dispatch. | |
- name: Github Release. | |
uses: softprops/action-gh-release@v1 | |
# Releases for tags only. | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
cyber-linux-x64.tar.gz | |
cyber-selinux-x64.tar.gz | |
cyber-macos-x64.tar.gz | |
cyber-macos-arm64.tar.gz | |
cyber-windows-x64.zip | |
libcyber-windows-gnu-x64.lib | |
libcyber-windows-msvc-x64.lib | |
libcyber-linux-x64.a | |
libcyber-macos-x64.a | |
libcyber-macos-arm64.a | |
cyber-web.wasm | |
cyber-wasi.wasm | |
docs.html | |
docs.md |