mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
358 lines
13 KiB
YAML
358 lines
13 KiB
YAML
name: Build Windows
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
runs-on:
|
|
type: string
|
|
default: windows
|
|
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
|
|
bun-version:
|
|
type: string
|
|
default: 1.1.7
|
|
|
|
env:
|
|
# Must specify exact version of LLVM for Windows
|
|
LLVM_VERSION: 16.0.6
|
|
BUN_VERSION: ${{ inputs.bun-version }}
|
|
BUN_GARBAGE_COLLECTOR_LEVEL: 1
|
|
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: 1
|
|
CI: true
|
|
|
|
jobs:
|
|
build-submodules:
|
|
name: Build Submodules
|
|
runs-on: ${{ inputs.runs-on }}
|
|
steps:
|
|
- name: Install VS2022 BuildTools 17.9.7
|
|
run: choco install -y visualstudio2022buildtools --version=117.9.7.0 --params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installChannelUri https://aka.ms/vs/17/release/180911598_-255012421/channel"
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global core.autocrlf false
|
|
git config --global core.eol lf
|
|
git config --system core.longpaths true
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: |
|
|
.gitmodules
|
|
src/deps
|
|
scripts
|
|
- name: Hash Submodules
|
|
id: hash
|
|
run: |
|
|
$data = "$(& {
|
|
git submodule | Where-Object { $_ -notmatch 'WebKit' }
|
|
echo "LLVM_VERSION=${{ env.LLVM_VERSION }}"
|
|
Get-Content -Path (Get-ChildItem -Path 'scripts/build*.ps1', 'scripts/all-dependencies.ps1', 'scripts/env.ps1' | Sort-Object -Property Name).FullName | Out-String
|
|
echo 1
|
|
})"
|
|
$hash = ( -join ((New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($data)) | ForEach-Object { $_.ToString("x2") } )).Substring(0, 10)
|
|
echo "hash=${hash}" >> $env:GITHUB_OUTPUT
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
id: cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: bun-deps
|
|
key: bun-${{ inputs.tag }}-deps-${{ steps.hash.outputs.hash }}
|
|
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
name: Install LLVM
|
|
uses: KyleMayes/install-llvm-action@8b37482c5a2997a3ab5dbf6561f8109e2eaa7d3b
|
|
with:
|
|
version: ${{ env.LLVM_VERSION }}
|
|
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
name: Install Ninja
|
|
run: |
|
|
choco install -y ninja
|
|
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
name: Clone Submodules
|
|
run: |
|
|
.\scripts\update-submodules.ps1
|
|
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
name: Build Dependencies
|
|
env:
|
|
CPU_TARGET: ${{ inputs.cpu }}
|
|
CCACHE_DIR: ccache
|
|
run: |
|
|
.\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }}
|
|
choco install -y nasm --version=2.16.01
|
|
$env:BUN_DEPS_OUT_DIR = (mkdir -Force "./bun-deps")
|
|
.\scripts\all-dependencies.ps1
|
|
- name: Save Cache
|
|
if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: 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: bun-deps
|
|
if-no-files-found: error
|
|
|
|
codegen:
|
|
name: Codegen
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global core.autocrlf false
|
|
git config --global core.eol lf
|
|
git config --system core.longpaths true
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: ${{ inputs.bun-version }}
|
|
- name: Codegen
|
|
run: |
|
|
./scripts/cross-compile-codegen.sh win32 x64
|
|
- if: ${{ inputs.canary }}
|
|
name: Calculate Revision
|
|
run: |
|
|
echo "canary_revision=$(GITHUB_TOKEN="${{ github.token }}"
|
|
bash ./scripts/calculate-canary-revision.sh --raw)" > build-codegen-win32-x64/.canary_revision
|
|
- name: Upload bun-${{ inputs.tag }}-codegen
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-codegen
|
|
path: build-codegen-win32-x64
|
|
if-no-files-found: error
|
|
|
|
build-cpp:
|
|
name: Build C++
|
|
needs: codegen
|
|
runs-on: ${{ inputs.runs-on }}
|
|
steps:
|
|
- name: Install VS2022 BuildTools 17.9.7
|
|
run: choco install -y visualstudio2022buildtools --version=117.9.7.0 --params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installChannelUri https://aka.ms/vs/17/release/180911598_-255012421/channel"
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global core.autocrlf false
|
|
git config --global core.eol lf
|
|
git config --system core.longpaths true
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- name: Install LLVM
|
|
uses: KyleMayes/install-llvm-action@8b37482c5a2997a3ab5dbf6561f8109e2eaa7d3b
|
|
with:
|
|
version: ${{ env.LLVM_VERSION }}
|
|
- name: Install Ninja
|
|
run: |
|
|
choco install -y ninja
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: ${{ inputs.bun-version }}
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: 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: Download bun-${{ inputs.tag }}-codegen
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-codegen
|
|
path: build
|
|
- name: Compile
|
|
env:
|
|
CPU_TARGET: ${{ inputs.cpu }}
|
|
CCACHE_DIR: ccache
|
|
run: |
|
|
# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
|
|
$CANARY_REVISION = 0
|
|
.\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }}
|
|
.\scripts\update-submodules.ps1
|
|
.\scripts\build-libuv.ps1 -CloneOnly $True
|
|
cd build
|
|
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
|
-DNO_CODEGEN=1 `
|
|
-DNO_CONFIGURE_DEPENDS=1 `
|
|
"-DCANARY=${CANARY_REVISION}" `
|
|
-DBUN_CPP_ONLY=1 ${{ contains(inputs.tag, '-baseline') && '-DUSE_BASELINE_BUILD=1' || '' }}
|
|
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
|
.\compile-cpp-only.ps1 -v
|
|
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
|
|
- name: Upload bun-${{ inputs.tag }}-cpp
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-cpp
|
|
path: build/bun-cpp-objects.a
|
|
if-no-files-found: error
|
|
|
|
build-zig:
|
|
name: Build Zig
|
|
uses: ./.github/workflows/build-zig.yml
|
|
with:
|
|
os: windows
|
|
only-zig: true
|
|
tag: ${{ inputs.tag }}
|
|
arch: ${{ inputs.arch }}
|
|
cpu: ${{ inputs.cpu }}
|
|
assertions: ${{ inputs.assertions }}
|
|
zig-optimize: ReleaseSafe
|
|
# Windows is always ReleaseSafe for now
|
|
# 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
|
|
- codegen
|
|
steps:
|
|
- name: Install VS2022 BuildTools 17.9.7
|
|
run: choco install -y visualstudio2022buildtools --version=117.9.7.0 --params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installChannelUri https://aka.ms/vs/17/release/180911598_-255012421/channel"
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global core.autocrlf false
|
|
git config --global core.eol lf
|
|
git config --system core.longpaths true
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- name: Install LLVM
|
|
uses: KyleMayes/install-llvm-action@8b37482c5a2997a3ab5dbf6561f8109e2eaa7d3b
|
|
with:
|
|
version: ${{ env.LLVM_VERSION }}
|
|
- name: Install Ninja
|
|
run: |
|
|
choco install -y ninja
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: ${{ inputs.bun-version }}
|
|
- name: Download bun-${{ inputs.tag }}-deps
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-deps
|
|
path: bun-deps
|
|
- name: Download bun-${{ inputs.tag }}-cpp
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-cpp
|
|
path: bun-cpp
|
|
- name: Download bun-${{ inputs.tag }}-zig
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-zig
|
|
path: bun-zig
|
|
- name: Download bun-${{ inputs.tag }}-codegen
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}-codegen
|
|
path: build
|
|
- if: ${{ !inputs.no-cache }}
|
|
name: Restore Cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: 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: ccache
|
|
run: |
|
|
.\scripts\update-submodules.ps1
|
|
.\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }}
|
|
Set-Location build
|
|
# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
|
|
$CANARY_REVISION = 0
|
|
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
|
-DNO_CODEGEN=1 `
|
|
-DNO_CONFIGURE_DEPENDS=1 `
|
|
"-DCANARY=${CANARY_REVISION}" `
|
|
-DBUN_LINK_ONLY=1 `
|
|
"-DBUN_DEPS_OUT_DIR=$(Resolve-Path ../bun-deps)" `
|
|
"-DBUN_CPP_ARCHIVE=$(Resolve-Path ../bun-cpp/bun-cpp-objects.a)" `
|
|
"-DBUN_ZIG_OBJ_DIR=$(Resolve-Path ../bun-zig)" `
|
|
${{ contains(inputs.tag, '-baseline') && '-DUSE_BASELINE_BUILD=1' || '' }}
|
|
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
|
ninja -v
|
|
if ($LASTEXITCODE -ne 0) { throw "Link failed!" }
|
|
- name: Prepare
|
|
run: |
|
|
$Dist = mkdir -Force "bun-${{ inputs.tag }}"
|
|
cp -r build\bun.exe "$Dist\bun.exe"
|
|
Compress-Archive -Force "$Dist" "${Dist}.zip"
|
|
$Dist = "$Dist-profile"
|
|
MkDir -Force "$Dist"
|
|
cp -r build\bun.exe "$Dist\bun.exe"
|
|
cp -r build\bun.pdb "$Dist\bun.pdb"
|
|
Compress-Archive -Force "$Dist" "$Dist.zip"
|
|
.\build\bun.exe --print "JSON.stringify(require('bun:internal-for-testing').crash_handler.getFeatureData())" > .\features.json
|
|
- name: Upload bun-${{ inputs.tag }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-${{ inputs.tag }}
|
|
path: 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: bun-${{ inputs.tag }}-profile.zip
|
|
if-no-files-found: error
|
|
- name: Upload bun-feature-data
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bun-feature-data
|
|
path: features.json
|
|
if-no-files-found: error
|
|
overwrite: true
|
|
|
|
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 }})**
|