Skip to content
Open
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
20 changes: 4 additions & 16 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ jobs:
label: unix
- os: windows-latest
label: windows-x64
bun-target-arch: x64
- os: windows-11-arm
label: windows-arm64
bun-target-arch: arm64

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -322,33 +324,19 @@ jobs:

- name: Install bun
uses: oven-sh/setup-bun@v2
if: ${{ matrix.os != 'windows-11-arm' }}
with:
bun-version-file: .bun-version
no-cache: true

- name: Install bun (Windows ARM)
if: ${{ matrix.os == 'windows-11-arm' }}
run: |
$bunVersion = (Get-Content .bun-version).Trim()
irm bun.sh/install.ps1 -OutFile install.ps1

# Bun doesn't have Windows ARM64 builds, so the setup-bun action fails. The install script however,
# does "support" it.

.\install.ps1 -Version $bunVersion

Join-Path (Resolve-Path ~).Path ".bun\bin" >> $env:GITHUB_PATH

# https://github.com/oven-sh/bun/issues/11198
- name: Fix cross-platform building on Actions
if: ${{ matrix.os != 'ubuntu-latest' }}
run: |
mkdir C:\test
cd C:\test
bun init -y
bun build --compile --target=bun-windows-x64 --outfile test index.ts
bun build --compile --target=bun-windows-x64-baseline --outfile test index.ts
bun build --compile --target=bun-windows-${{ matrix.bun-target-arch }} --outfile test index.ts
bun build --compile --target=bun-windows-${{ matrix.bun-target-arch }}-baseline --outfile test index.ts

- name: Build Bundles
run: yarn insert-cli-metadata && yarn build-bundles
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/pre_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ jobs:
label: unix
- os: windows-latest
label: windows-x64
bun-target-arch: x64
- os: windows-11-arm
label: windows-arm64
bun-target-arch: arm64

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -145,32 +147,18 @@ jobs:

- name: Install bun
uses: oven-sh/setup-bun@v2
if: ${{ matrix.os != 'windows-11-arm' }}
with:
bun-version-file: .bun-version

- name: Install bun (Windows ARM)
if: ${{ matrix.os == 'windows-11-arm' }}
run: |
$bunVersion = (Get-Content .bun-version).Trim()
irm bun.sh/install.ps1 -OutFile install.ps1

# Bun doesn't have Windows ARM64 builds, so the setup-bun action fails. The install script however,
# does "support" it.

.\install.ps1 -Version $bunVersion

Join-Path (Resolve-Path ~).Path ".bun\bin" >> $env:GITHUB_PATH

# https://github.com/oven-sh/bun/issues/11198
- name: Fix cross-platform building on Actions
if: ${{ matrix.os != 'ubuntu-latest' }}
run: |
mkdir C:\test
cd C:\test
bun init -y
bun build --compile --target=bun-windows-x64 --outfile test index.ts
bun build --compile --target=bun-windows-x64-baseline --outfile test index.ts
bun build --compile --target=bun-windows-${{ matrix.bun-target-arch }} --outfile test index.ts
bun build --compile --target=bun-windows-${{ matrix.bun-target-arch }}-baseline --outfile test index.ts

- name: Set pre-release version
run: yarn version ${{ needs.update_changelog.outputs.pre_release_version }}
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ jobs:
label: unix
- os: windows-latest
label: windows-x64
bun-target-arch: x64
- os: windows-11-arm
label: windows-arm64
bun-target-arch: arm64

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -172,32 +174,18 @@ jobs:

- name: Install bun
uses: oven-sh/setup-bun@v2
if: ${{ matrix.os != 'windows-11-arm' }}
with:
bun-version-file: .bun-version

- name: Install bun (Windows ARM)
if: ${{ matrix.os == 'windows-11-arm' }}
run: |
$bunVersion = (Get-Content .bun-version).Trim()
irm bun.sh/install.ps1 -OutFile install.ps1

# Bun doesn't have Windows ARM64 builds, so the setup-bun action fails. The install script however,
# does "support" it.

.\install.ps1 -Version $bunVersion

Join-Path (Resolve-Path ~).Path ".bun\bin" >> $env:GITHUB_PATH

# https://github.com/oven-sh/bun/issues/11198
- name: Fix cross-platform building on Actions
if: ${{ matrix.os != 'ubuntu-latest' }}
run: |
mkdir C:\test
cd C:\test
bun init -y
bun build --compile --target=bun-windows-x64 --outfile test index.ts
bun build --compile --target=bun-windows-x64-baseline --outfile test index.ts
bun build --compile --target=bun-windows-${{ matrix.bun-target-arch }} --outfile test index.ts
bun build --compile --target=bun-windows-${{ matrix.bun-target-arch }}-baseline --outfile test index.ts

- name: Set version
run: yarn version ${{ needs.release_metadata.outputs.version_number }}
Expand Down
29 changes: 6 additions & 23 deletions scripts/build-cli-bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { readFileSync } from 'node:fs';
import { readFile, rm, writeFile } from 'node:fs/promises';
import { basename } from 'node:path';

import { $, type Build, build, fileURLToPath } from 'bun';
import { type Build, build, fileURLToPath } from 'bun';

import { version } from '../package.json' with { type: 'json' };

Expand All @@ -21,6 +21,7 @@ const targets = (() => {
//
'bun-windows-x64',
'bun-windows-x64-baseline',
'bun-windows-arm64',
'bun-linux-x64',
'bun-linux-x64-baseline',
'bun-linux-arm64',
Expand All @@ -31,13 +32,16 @@ const targets = (() => {
'bun-darwin-arm64-baseline',
'bun-linux-x64-musl',
'bun-linux-arm64-musl',
// TODO: when adding native windows arm64 builds, remove these too
'bun-linux-x64-musl-baseline' as never,
'bun-linux-arm64-musl-baseline' as never,
] satisfies Build.CompileTarget[];
}

if (process.platform === 'win32') {
if (process.arch === 'arm64') {
return ['bun-windows-arm64'] satisfies Build.CompileTarget[];
}

return ['bun-windows-x64', 'bun-windows-x64-baseline'] satisfies Build.CompileTarget[];
}

Expand Down Expand Up @@ -117,24 +121,6 @@ for (const entryPoint of entryPoints) {
baseline = 'baseline';
}

// If we are building on Windows ARM64, even though the target is x64, we mark it as "arm64" (there are some weird errors when compiling on x64
// and running on arm64). Hopefully bun will get arm64 native builds
// TODO: Vlad remove this in a subsequent PR as Bun now has native arm64 windows builds
if (os === 'windows' && process.platform === 'win32') {
const systemType = await $`pwsh -c "(Get-CimInstance Win32_ComputerSystem).SystemType"`.text();

if (systemType.toLowerCase().includes('arm')) {
arch = 'arm64';

// On arm, process.arch will still return x64, which will break the upgrade command.
// So we override the arch to arm64

const newNewContent = newContent.replace('process.env.APIFY_BUNDLE_ARCH', '"arm64"');

await writeFile(metadataFile, newNewContent);
}
}

const fileName = `${cliName}-${version}-${os}-${arch}${musl ? '-musl' : ''}${baseline ? '-baseline' : ''}`;

const outFile = fileURLToPath(new URL(`../bundles/${fileName}`, import.meta.url));
Expand All @@ -155,9 +141,6 @@ for (const entryPoint of entryPoints) {
},
bytecode: true,
});

// Remove the arch override
await writeFile(metadataFile, newContent);
}
}

Expand Down
30 changes: 14 additions & 16 deletions scripts/install/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ param(
# The following script is adapted from the bun.sh install script
# Licensed under the MIT License (https://github.com/oven-sh/bun/blob/main/LICENSE.md)

$allowedSystemTypes = @("x64-based", "ARM64-based")
$currentSystemType = (Get-CimInstance Win32_ComputerSystem).SystemType

$Arch = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment').PROCESSOR_ARCHITECTURE
# filter out 32 bit
if (-not ($allowedSystemTypes | Where-Object { $currentSystemType -match $_ })) {
if (-not ($Arch -eq "AMD64" -or $Arch -eq "ARM64")) {
Write-Output "Install Failed:"
Write-Output "Apify CLI for Windows is currently only available for 64-bit Windows and ARM64 Windows.`n"
return 1
}

if ($currentSystemType -match "ARM64") {
Write-Warning "Warning:"
Write-Warning "ARM64-based systems are not natively supported yet.`nThe install will still continue but Apify CLI might not work as intended.`n"
}

# This corresponds to .win10_rs5 in build.zig
$MinBuild = 17763;
$MinBuildName = "Windows 10 1809 / Windows Server 2019"
Expand Down Expand Up @@ -114,13 +107,18 @@ function Install-Apify {
return 1
}

$Arch = if ($currentSystemType -match "ARM64") { "arm64" } else { "x64" }
$IsBaseline = $ForceBaseline

if (-not $IsBaseline) {
$IsBaseline = !(
Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' -Name 'Kernel32' -Namespace 'Win32' -PassThru
)::IsProcessorFeaturePresent(40)
$IsARM64 = $Arch -eq "ARM64"
$Arch = if ($IsARM64) { "arm64" } else { "x64" }
$IsBaseline = $false

if (-not $IsARM64) {
$IsBaseline = $ForceBaseline
if (-not $IsBaseline) {
$IsBaseline = !( `
Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' `
-Name 'Kernel32' -Namespace 'Win32' -PassThru `
)::IsProcessorFeaturePresent(40);
}
}

$ApifyRoot = if ($env:APIFY_CLI_INSTALL) { $env:APIFY_CLI_INSTALL } else { "${Home}\.apify" }
Expand Down
10 changes: 8 additions & 2 deletions scripts/install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ case $platform in
target=darwin-x64
;;
'Darwin arm64')
target=darwin-arm64
target=darwin-aarch64
;;
'Linux aarch64' | 'Linux arm64')
target=linux-arm64
target=linux-aarch64
;;
'MINGW64'*'ARM64'* | 'MINGW64'*'aarch64'*)
target=windows-aarch64
;;
'MINGW64'*)
target=windows-x64
;;
'Linux riscv64')
error 'Not supported on riscv64'
;;
'Linux x86_64' | *)
target=linux-x64
;;
Expand Down