mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
316 lines
10 KiB
YAML
316 lines
10 KiB
YAML
name: Build Darwin
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
runs-on:
|
|
type: string
|
|
default: macos-12-large
|
|
tag:
|
|
type: string
|
|
required: true
|
|
arch:
|
|
type: string
|
|
required: true
|
|
cpu:
|
|
type: string
|
|
required: true
|
|
assertions:
|
|
type: boolean
|
|
zig-optimize:
|
|
type: string
|
|
canary:
|
|
type: boolean
|
|
no-cache:
|
|
type: boolean
|
|
|
|
env:
|
|
LLVM_VERSION: 16
|
|
BUN_VERSION: 1.1.8
|
|
LC_CTYPE: "en_US.UTF-8"
|
|
LC_ALL: "en_US.UTF-8"
|
|
|
|
jobs:
|
|
build-submodules:
|
|
name: Build Submodules
|
|
runs-on: ${{ inputs.runs-on }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: |
|
|
.gitmodules
|
|
src/deps
|
|
scripts
|
|
- name: Hash Submodules
|
|
id: hash
|
|
run: |
|
|
print_versions() {
|
|
git submodule | grep -v WebKit
|
|
echo "LLVM_VERSION=${{ env.LLVM_VERSION }}"
|
|
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
|
|
}
|
|
echo "hash=$(print_versions | shasum)" >> $GITHUB_OUTPUT
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
id: cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ${{ runner.temp }}/bun-deps
|
|
key: bun-${{ inputs.tag }}-deps-${{ steps.hash.outputs.hash }}
|
|
# TODO: Figure out how to cache homebrew dependencies
|
|
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
name: Install Dependencies
|
|
env:
|
|
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
|
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
|
run: |
|
|
brew install \
|
|
llvm@${{ env.LLVM_VERSION }} \
|
|
ccache \
|
|
rust \
|
|
pkg-config \
|
|
coreutils \
|
|
libtool \
|
|
cmake \
|
|
libiconv \
|
|
automake \
|
|
openssl@1.1 \
|
|
ninja \
|
|
golang \
|
|
gnu-sed --force --overwrite
|
|
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
|
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
|
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
|
brew link --overwrite llvm@$LLVM_VERSION
|
|
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
name: Clone Submodules
|
|
run: |
|
|
./scripts/update-submodules.sh
|
|
- name: Build Submodules
|
|
if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
env:
|
|
CPU_TARGET: ${{ inputs.cpu }}
|
|
BUN_DEPS_OUT_DIR: ${{ runner.temp }}/bun-deps
|
|
run: |
|
|
mkdir -p $BUN_DEPS_OUT_DIR
|
|
./scripts/all-dependencies.sh
|
|
- name: Save Cache
|
|
if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: ${{ runner.temp }}/bun-deps
|
|
key: ${{ steps.cache.outputs.cache-primary-key }}
|
|
- name: Upload bun-${{ inputs.tag }}-deps
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-deps
|
|
path: ${{ runner.temp }}/bun-deps
|
|
if-no-files-found: error
|
|
build-cpp:
|
|
name: Build C++
|
|
runs-on: ${{ inputs.runs-on }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
# TODO: Figure out how to cache homebrew dependencies
|
|
- name: Install Dependencies
|
|
env:
|
|
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
|
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
|
run: |
|
|
brew install \
|
|
llvm@${{ env.LLVM_VERSION }} \
|
|
ccache \
|
|
rust \
|
|
pkg-config \
|
|
coreutils \
|
|
libtool \
|
|
cmake \
|
|
libiconv \
|
|
automake \
|
|
openssl@1.1 \
|
|
ninja \
|
|
golang \
|
|
gnu-sed --force --overwrite
|
|
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
|
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
|
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
|
brew link --overwrite llvm@$LLVM_VERSION
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: ${{ env.BUN_VERSION }}
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ runner.temp }}/ccache
|
|
key: bun-${{ inputs.tag }}-cpp-${{ hashFiles('Dockerfile', 'Makefile', 'CMakeLists.txt', 'build.zig', 'scripts/**', 'src/**', 'packages/bun-usockets/src/**', 'packages/bun-uws/src/**') }}
|
|
restore-keys: |
|
|
bun-${{ inputs.tag }}-cpp-
|
|
- name: Compile
|
|
env:
|
|
CPU_TARGET: ${{ inputs.cpu }}
|
|
SOURCE_DIR: ${{ github.workspace }}
|
|
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
|
BUN_DEPS_OUT_DIR: ${{ runner.temp }}/bun-deps
|
|
CCACHE_DIR: ${{ runner.temp }}/ccache
|
|
run: |
|
|
mkdir -p $OBJ_DIR
|
|
cd $OBJ_DIR
|
|
cmake -S $SOURCE_DIR -B $OBJ_DIR \
|
|
-G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DUSE_LTO=ON \
|
|
-DBUN_CPP_ONLY=1 \
|
|
-DNO_CONFIGURE_DEPENDS=1
|
|
chmod +x compile-cpp-only.sh
|
|
./compile-cpp-only.sh -v
|
|
- name: Upload bun-${{ inputs.tag }}-cpp
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-cpp
|
|
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
|
|
if-no-files-found: error
|
|
build-zig:
|
|
name: Build Zig
|
|
uses: ./.github/workflows/build-zig.yml
|
|
with:
|
|
os: darwin
|
|
only-zig: true
|
|
tag: ${{ inputs.tag }}
|
|
arch: ${{ inputs.arch }}
|
|
cpu: ${{ inputs.cpu }}
|
|
assertions: ${{ inputs.assertions }}
|
|
zig-optimize: ${{ inputs.zig-optimize }}
|
|
canary: ${{ inputs.canary }}
|
|
no-cache: ${{ inputs.no-cache }}
|
|
link:
|
|
name: Link
|
|
runs-on: ${{ inputs.runs-on }}
|
|
needs:
|
|
- build-submodules
|
|
- build-cpp
|
|
- build-zig
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
# TODO: Figure out how to cache homebrew dependencies
|
|
- name: Install Dependencies
|
|
env:
|
|
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
|
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
|
run: |
|
|
brew install \
|
|
llvm@${{ env.LLVM_VERSION }} \
|
|
ccache \
|
|
rust \
|
|
pkg-config \
|
|
coreutils \
|
|
libtool \
|
|
cmake \
|
|
libiconv \
|
|
automake \
|
|
openssl@1.1 \
|
|
ninja \
|
|
golang \
|
|
gnu-sed --force --overwrite
|
|
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
|
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
|
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
|
brew link --overwrite llvm@$LLVM_VERSION
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: ${{ env.BUN_VERSION }}
|
|
- name: Download bun-${{ inputs.tag }}-deps
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-deps
|
|
path: ${{ runner.temp }}/bun-deps
|
|
- name: Download bun-${{ inputs.tag }}-cpp
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-cpp
|
|
path: ${{ runner.temp }}/bun-cpp-obj
|
|
- name: Download bun-${{ inputs.tag }}-zig
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-zig
|
|
path: ${{ runner.temp }}/release
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ runner.temp }}/ccache
|
|
key: bun-${{ inputs.tag }}-cpp-${{ hashFiles('Dockerfile', 'Makefile', 'CMakeLists.txt', 'build.zig', 'scripts/**', 'src/**', 'packages/bun-usockets/src/**', 'packages/bun-uws/src/**') }}
|
|
restore-keys: |
|
|
bun-${{ inputs.tag }}-cpp-
|
|
- name: Link
|
|
env:
|
|
CPU_TARGET: ${{ inputs.cpu }}
|
|
CCACHE_DIR: ${{ runner.temp }}/ccache
|
|
run: |
|
|
SRC_DIR=$PWD
|
|
mkdir ${{ runner.temp }}/link-build
|
|
cd ${{ runner.temp }}/link-build
|
|
cmake $SRC_DIR \
|
|
-G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DUSE_LTO=ON \
|
|
-DBUN_LINK_ONLY=1 \
|
|
-DBUN_ZIG_OBJ_DIR="${{ runner.temp }}/release" \
|
|
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
|
|
-DBUN_DEPS_OUT_DIR="${{ runner.temp }}/bun-deps" \
|
|
-DNO_CONFIGURE_DEPENDS=1
|
|
ninja -v
|
|
- name: Prepare
|
|
run: |
|
|
cd ${{ runner.temp }}/link-build
|
|
chmod +x bun-profile bun
|
|
mkdir -p bun-${{ inputs.tag }}-profile/ bun-${{ inputs.tag }}/
|
|
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 }}
|
|
- name: Upload bun-${{ inputs.tag }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}
|
|
path: ${{ runner.temp }}/link-build/bun-${{ inputs.tag }}.zip
|
|
if-no-files-found: error
|
|
- name: Upload bun-${{ inputs.tag }}-profile
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-profile
|
|
path: ${{ runner.temp }}/link-build/bun-${{ inputs.tag }}-profile.zip
|
|
if-no-files-found: error
|
|
on-failure:
|
|
if: ${{ github.repository_owner == 'oven-sh' && failure() }}
|
|
name: On Failure
|
|
needs: link
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Send Message
|
|
uses: sarisia/actions-status-discord@v1
|
|
with:
|
|
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
|
nodetail: true
|
|
color: "#FF0000"
|
|
title: ""
|
|
description: |
|
|
### ❌ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})
|
|
|
|
@${{ github.actor }}, the build for bun-${{ inputs.tag }} failed.
|
|
|
|
**[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})**
|