Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/actions/setup-bun-compile-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Setup Bun Compile Runtime'
description: 'Download and cache a Bun runtime used by bun build --compile-executable-path'

inputs:
target:
description: 'Bun compile target, for example bun-windows-x64-baseline'
required: true

runs:
using: 'composite'
steps:
- name: Get Bun version
id: bun-version
shell: bash
run: echo "version=$(bun --version)" >> "$GITHUB_OUTPUT"

- name: Cache Bun compile runtime
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/bun-compile-runtimes/${{ inputs.target }}-v${{ steps.bun-version.outputs.version }}
key: ${{ runner.os }}-bun-compile-runtime-${{ inputs.target }}-v${{ steps.bun-version.outputs.version }}

- name: Prepare Bun compile runtime
shell: pwsh
env:
BUN_COMPILE_TARGET: ${{ inputs.target }}
BUN_VERSION: ${{ steps.bun-version.outputs.version }}
RUNTIME_DIR: ${{ runner.temp }}/bun-compile-runtimes/${{ inputs.target }}-v${{ steps.bun-version.outputs.version }}
run: |
$ErrorActionPreference = 'Stop'

$runtimePath = Join-Path $env:RUNTIME_DIR 'bun.exe'
if (!(Test-Path -LiteralPath $runtimePath)) {
New-Item -ItemType Directory -Force -Path $env:RUNTIME_DIR | Out-Null

$zipPath = Join-Path $env:RUNTIME_DIR "$($env:BUN_COMPILE_TARGET).zip"
$downloadUrl = "https://github.com/oven-sh/bun/releases/download/bun-v$($env:BUN_VERSION)/$($env:BUN_COMPILE_TARGET).zip"

Write-Host "Downloading $($env:BUN_COMPILE_TARGET): $downloadUrl"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
Expand-Archive -LiteralPath $zipPath -DestinationPath $env:RUNTIME_DIR -Force

$extractedRuntimePath = Join-Path $env:RUNTIME_DIR "$($env:BUN_COMPILE_TARGET)/bun.exe"
if (!(Test-Path -LiteralPath $extractedRuntimePath)) {
throw "Downloaded $($env:BUN_COMPILE_TARGET), but bun.exe was not found at $extractedRuntimePath"
}

Copy-Item -LiteralPath $extractedRuntimePath -Destination $runtimePath -Force
}

"BUN_COMPILE_EXECUTABLE_PATH=$runtimePath" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
7 changes: 6 additions & 1 deletion .github/workflows/cli-release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,18 @@ jobs:
echo "$ENV_OVERRIDES" | jq -r 'to_entries | .[] | .key + "=" + .value' >> $GITHUB_ENV
fi

- name: Prepare Windows baseline Bun compile runtime
uses: ./.github/actions/setup-bun-compile-runtime
with:
target: bun-windows-x64-baseline

- name: Build binary
run: bun run scripts/build-binary.ts ${{ inputs.binary-name }} ${{ inputs.new-version }}
working-directory: cli
shell: bash
env:
VERBOSE: true
OVERRIDE_TARGET: bun-windows-x64
OVERRIDE_TARGET: bun-windows-x64-baseline
OVERRIDE_PLATFORM: win32
OVERRIDE_ARCH: x64

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/freebuff-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ jobs:
echo "NEXT_PUBLIC_CB_ENVIRONMENT=prod" >> $GITHUB_ENV
echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV

- name: Prepare Windows baseline Bun compile runtime
uses: ./.github/actions/setup-bun-compile-runtime
with:
target: bun-windows-x64-baseline

- name: Build Freebuff binary
run: bun freebuff/cli/build.ts 0.0.0-e2e
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-app-release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
arch: arm64
- os: windows-latest
target: win32-x64
bun_target: bun-windows-x64
bun_target: bun-windows-x64-baseline
platform: win32
arch: x64
runs-on: ${{ matrix.os }}
Expand Down
7 changes: 6 additions & 1 deletion cli/scripts/build-binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const OVERRIDE_PLATFORM = process.env.OVERRIDE_PLATFORM as
| NodeJS.Platform
| undefined
const OVERRIDE_ARCH = process.env.OVERRIDE_ARCH ?? undefined
const OVERRIDE_COMPILE_EXECUTABLE_PATH =
process.env.BUN_COMPILE_EXECUTABLE_PATH

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
Expand Down Expand Up @@ -95,7 +97,7 @@ function getTargetInfo(): TargetInfo {
arch: 'arm64',
},
'win32-x64': {
bunTarget: 'bun-windows-x64',
bunTarget: 'bun-windows-x64-baseline',
platform: 'win32',
arch: 'x64',
},
Expand Down Expand Up @@ -172,6 +174,9 @@ async function main() {
'--compile',
'--production', // Required so compiled binaries use the production JSX runtime (avoids jsxDEV crashes).
`--target=${targetInfo.bunTarget}`,
...(OVERRIDE_COMPILE_EXECUTABLE_PATH
? [`--compile-executable-path=${OVERRIDE_COMPILE_EXECUTABLE_PATH}`]
: []),
`--outfile=${outputFile}`,
'--sourcemap=none',
...defineFlags.flatMap(([key, value]) => ['--define', `${key}=${value}`]),
Expand Down
Loading