mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
123 lines
4.6 KiB
YAML
123 lines
4.6 KiB
YAML
name: Build Zig
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
runs-on:
|
|
type: string
|
|
default: ${{ github.repository_owner != 'oven-sh' && 'ubuntu-latest' || inputs.only-zig && 'namespace-profile-bun-ci-linux-x64' || inputs.arch == 'x64' && 'namespace-profile-bun-ci-linux-x64' || 'namespace-profile-bun-ci-linux-aarch64' }}
|
|
tag:
|
|
type: string
|
|
required: true
|
|
os:
|
|
type: string
|
|
required: true
|
|
arch:
|
|
type: string
|
|
required: true
|
|
cpu:
|
|
type: string
|
|
required: true
|
|
assertions:
|
|
type: boolean
|
|
default: false
|
|
zig-optimize:
|
|
type: string # 'ReleaseSafe' or 'ReleaseFast'
|
|
default: ReleaseFast
|
|
canary:
|
|
type: boolean
|
|
default: ${{ github.ref == 'refs/heads/main' }}
|
|
only-zig:
|
|
type: boolean
|
|
default: true
|
|
no-cache:
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
build-zig:
|
|
name: ${{ inputs.only-zig && 'Build Zig' || 'Build & Link' }}
|
|
runs-on: ${{ inputs.runs-on }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Calculate Cache Key
|
|
id: cache
|
|
run: |
|
|
echo "key=${{ hashFiles('Dockerfile', 'Makefile', 'CMakeLists.txt', 'build.zig', 'scripts/**', 'src/**', 'packages/bun-usockets/src/**', 'packages/bun-uws/src/**') }}" >> $GITHUB_OUTPUT
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
key: bun-${{ inputs.tag }}-docker-${{ steps.cache.outputs.key }}
|
|
restore-keys: |
|
|
bun-${{ inputs.tag }}-docker-
|
|
path: |
|
|
${{ runner.temp }}/dockercache
|
|
- name: Setup Docker
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
install: true
|
|
platforms: |
|
|
linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
|
- name: Build
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
push: false
|
|
target: ${{ inputs.only-zig && 'build_release_obj' || 'artifact' }}
|
|
cache-from: |
|
|
type=local,src=${{ runner.temp }}/dockercache
|
|
cache-to: |
|
|
type=local,dest=${{ runner.temp }}/dockercache,mode=max
|
|
outputs: |
|
|
type=local,dest=${{ runner.temp }}/release
|
|
platforms: |
|
|
linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
|
build-args: |
|
|
GIT_SHA=${{ github.event.workflow_run.head_sha || github.sha }}
|
|
TRIPLET=${{ inputs.os == 'darwin' && format('{0}-macos-none', inputs.arch == 'x64' && 'x86_64' || 'aarch64') || inputs.os == 'windows' && format('{0}-windows-msvc', inputs.arch == 'x64' && 'x86_64' || 'aarch64') || format('{0}-linux-gnu', inputs.arch == 'x64' && 'x86_64' || 'aarch64') }}
|
|
ARCH=${{ inputs.arch == 'x64' && 'x86_64' || 'aarch64' }}
|
|
BUILDARCH=${{ inputs.arch == 'x64' && 'amd64' || 'arm64' }}
|
|
BUILD_MACHINE_ARCH=${{ inputs.arch == 'x64' && 'x86_64' || 'aarch64' }}
|
|
CPU_TARGET=${{ inputs.arch == 'x64' && inputs.cpu || 'native' }}
|
|
ASSERTIONS=${{ inputs.assertions && 'ON' || 'OFF' }}
|
|
ZIG_OPTIMIZE=${{ inputs.zig-optimize }}
|
|
CANARY=${{ inputs.canary && '1' || '0' }}
|
|
- if: ${{ inputs.only-zig }}
|
|
name: Upload bun-${{ inputs.tag }}-zig
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-zig
|
|
path: ${{ runner.temp }}/release/bun-zig.o
|
|
if-no-files-found: error
|
|
- if: ${{ !inputs.only-zig }}
|
|
name: Prepare
|
|
run: |
|
|
cd ${{ runner.temp }}/release
|
|
chmod +x bun-profile bun
|
|
mkdir bun-${{ inputs.tag }}-profile
|
|
mkdir bun-${{ inputs.tag }}
|
|
strip bun
|
|
mv bun-profile bun-${{ inputs.tag }}-profile/bun-profile
|
|
mv bun bun-${{ inputs.tag }}/bun
|
|
zip -r bun-${{ inputs.tag }}-profile.zip bun-${{ inputs.tag }}-profile
|
|
zip -r bun-${{ inputs.tag }}.zip bun-${{ inputs.tag }}
|
|
- if: ${{ !inputs.only-zig }}
|
|
name: Upload bun-${{ inputs.tag }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}
|
|
path: ${{ runner.temp }}/release/bun-${{ inputs.tag }}.zip
|
|
if-no-files-found: error
|
|
- if: ${{ !inputs.only-zig }}
|
|
name: Upload bun-${{ inputs.tag }}-profile
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-profile
|
|
path: ${{ runner.temp }}/release/bun-${{ inputs.tag }}-profile.zip
|
|
if-no-files-found: error
|