Skip to content

BRE-536/Add-ARM-targz-builds-for-desktop-and-cli #14270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bc0fea0
Test ARM64 build
vgrassia Feb 6, 2025
d638f84
Remove sudo
vgrassia Feb 6, 2025
aff6c85
Change to public preview runner
vgrassia Feb 6, 2025
320ec8f
Change cache key for architectures
vgrassia Feb 6, 2025
35d0363
Test
vgrassia Feb 7, 2025
b6a849f
Test
vgrassia Feb 7, 2025
14f6d4a
Test
vgrassia Feb 7, 2025
c6bceaa
remove x86 musl target - troubleshooting build error
aj-bw Apr 9, 2025
eb05627
native module troubleshooting
aj-bw Apr 9, 2025
fea183e
remove cross-platform for testing
aj-bw Apr 9, 2025
458e467
attempt to resolve cross-platform issue
aj-bw Apr 9, 2025
baedae6
support more arm64 build types
aj-bw Apr 10, 2025
341e112
fix missed amd to arm update
aj-bw Apr 10, 2025
dba6495
missing dependency during env setup
aj-bw Apr 10, 2025
75ecdd2
lxd troubleshooting
aj-bw Apr 10, 2025
a124526
install lxd with snap instead
aj-bw Apr 10, 2025
057ec20
electron-builder debug
aj-bw Apr 10, 2025
9bafe29
simplified script for testing
aj-bw Apr 10, 2025
db6f27e
testing
aj-bw Apr 10, 2025
9ac0ff6
22.04 to 20.04
aj-bw Apr 10, 2025
04dc34f
try ubuntu 24.04 runner
aj-bw Apr 10, 2025
6171736
add dist script
aj-bw Apr 10, 2025
6699dc1
update build command
aj-bw Apr 10, 2025
5b45932
troubleshoot 24.04 compatibility
aj-bw Apr 10, 2025
704c151
remove lxd before merging main
aj-bw Apr 11, 2025
951253f
Merge remote-tracking branch 'origin/main' into bre-536_add-arm-buildโ€ฆ
aj-bw Apr 11, 2025
7657d04
add comment, bump arm runner down to 22.04
aj-bw Apr 11, 2025
b74c96a
revert to tar.gz support only for this PR
aj-bw Apr 11, 2025
39228a6
testing cli arm builds
aj-bw Apr 11, 2025
f0c291b
fix build target designation
aj-bw Apr 14, 2025
612d59d
adjust runner designation
aj-bw Apr 14, 2025
ee7b2fb
runner name typo
aj-bw Apr 14, 2025
66bf454
not needed currently
aj-bw Apr 14, 2025
950787c
adjust build.js logic and call in workflow
aj-bw Apr 15, 2025
4e35cc9
address styling feedback and unnecessary rust toolchain call
aj-bw Apr 15, 2025
2d53ffc
simplify build cli os matrix
aj-bw Apr 16, 2025
41819c8
revert x86 linux builds to cross-platform command for build.js
aj-bw Apr 16, 2025
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
5 changes: 3 additions & 2 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
os:
[
{ base: "linux", distro: "ubuntu-22.04", target_suffix: "" },
{ base: "linux", distro: "ubuntu-22.04-arm", target_suffix: "-arm64" },
{ base: "mac", distro: "macos-13", target_suffix: "" },
{ base: "mac", distro: "macos-14", target_suffix: "-arm64" }
]
Expand Down Expand Up @@ -130,7 +131,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down Expand Up @@ -306,7 +307,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down
109 changes: 103 additions & 6 deletions .github/workflows/build-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down Expand Up @@ -298,6 +298,103 @@ jobs:
if-no-files-found: error


linux-arm64:
name: Linux ARM64 Build
# Note, before updating the ubuntu version of the workflow, ensure the snap base image
# is equal or greater than the new version. Otherwise there might be GLIBC version issues.
# The snap base for desktop is defined in `apps/desktop/electron-builder.json`
# We intentionally keep this runner on the oldest supported OS in GitHub Actions
# for maximum compatibility across GLIBC versions
runs-on: ubuntu-22.04-arm
needs: setup
env:
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
NODE_OPTIONS: --max_old_space_size=4096
defaults:
run:
working-directory: apps/desktop
steps:
- name: Check out repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
node-version: ${{ env._NODE_VERSION }}

- name: Set up environment
run: |
sudo apt-get update
sudo apt-get -y install pkg-config libxss-dev rpm musl-dev musl-tools flatpak flatpak-builder

- name: Print environment
run: |
node --version
npm --version
snap --version
snapcraft --version || echo 'snapcraft unavailable'

- name: Install Node dependencies
run: npm ci
working-directory: ./

- name: Download SDK Artifacts
if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
artifacts: sdk-internal
repo: bitwarden/sdk-internal
path: ../sdk-internal
if_no_artifact_found: fail

- name: Override SDK
if: ${{ inputs.sdk_branch != '' }}
working-directory: ./
run: |
ls -l ../
npm link ../sdk-internal

- name: Cache Native Module
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: cache
with:
path: |
apps/desktop/desktop_native/napi/*.node
apps/desktop/desktop_native/dist/*
${{ env.RUNNER_TEMP }}/.cargo/registry
${{ env.RUNNER_TEMP }}/.cargo/git
key: rust-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}

- name: Build Native Module
if: steps.cache.outputs.cache-hit != 'true'
working-directory: apps/desktop/desktop_native
env:
PKG_CONFIG_ALLOW_CROSS: true
PKG_CONFIG_ALL_STATIC: true
TARGET: musl
run: |
rustup target add aarch64-unknown-linux-musl
node build.js --target=aarch64-unknown-linux-musl --release

- name: Build application
run: npm run dist:lin:arm64

- name: Upload tar.gz artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: bitwarden_${{ env._PACKAGE_VERSION }}_arm64.tar.gz
path: apps/desktop/dist/bitwarden_desktop_arm64.tar.gz
if-no-files-found: error

windows:
name: Windows Build
runs-on: windows-2022
Expand Down Expand Up @@ -369,7 +466,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down Expand Up @@ -705,7 +802,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down Expand Up @@ -895,7 +992,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down Expand Up @@ -1144,7 +1241,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down Expand Up @@ -1425,7 +1522,7 @@ jobs:
if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main
with:
github_token: ${{secrets.GITHUB_TOKEN}}
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.sdk_branch }}
Expand Down
4 changes: 4 additions & 0 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@
"dist:oss:mac": "npm run build:oss:prod && npm run clean && npm run package:oss:mac",
"dist:oss:mac-arm64": "npm run build:oss:prod && npm run clean && npm run package:oss:mac-arm64",
"dist:oss:lin": "npm run build:oss:prod && npm run clean && npm run package:oss:lin",
"dist:oss:lin-arm64": "npm run build:oss:prod && npm run clean && npm run package:oss:lin-arm64",
"dist:bit:win": "npm run build:bit:prod && npm run clean && npm run package:bit:win",
"dist:bit:mac": "npm run build:bit:prod && npm run clean && npm run package:bit:mac",
"dist:bit:mac-arm64": "npm run build:bit:prod && npm run clean && npm run package:bit:mac-arm64",
"dist:bit:lin": "npm run build:bit:prod && npm run clean && npm run package:bit:lin",
"dist:bit:lin-arm64": "npm run build:bit:prod && npm run clean && npm run package:bit:lin-arm64",
"package:oss:win": "pkg . --targets win-x64 --output ./dist/oss/windows/bw.exe",
"package:oss:mac": "pkg . --targets macos-x64 --output ./dist/oss/macos/bw",
"package:oss:mac-arm64": "pkg . --targets macos-arm64 --output ./dist/oss/macos-arm64/bw",
"package:oss:lin": "pkg . --targets linux-x64 --output ./dist/oss/linux/bw",
"package:oss:lin-arm64": "pkg . --targets linux-arm64 --output ./dist/oss/linux-arm64/bw",
"package:bit:win": "pkg . --targets win-x64 --output ./dist/bit/windows/bw.exe",
"package:bit:mac": "pkg . --targets macos-x64 --output ./dist/bit/macos/bw",
"package:bit:mac-arm64": "pkg . --targets macos-arm64 --output ./dist/bit/macos-arm64/bw",
"package:bit:lin": "pkg . --targets linux-x64 --output ./dist/bit/linux/bw",
"package:bit:lin-arm64": "pkg . --targets linux-arm64 --output ./dist/bit/linux-arm64/bw",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
Expand Down
22 changes: 17 additions & 5 deletions apps/desktop/desktop_native/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const child_process = require("child_process");
const fs = require("fs");
const path = require("path");
const process = require("process");
const args = process.argv.slice(2); // Get arguments passed to the script
const mode = args.includes("--release") ? "release" : "debug";
const targetArg = args.find(arg => arg.startsWith("--target="));
const target = targetArg ? targetArg.split("=")[1] : null;

let crossPlatform = process.argv.length > 2 && process.argv[2] === "cross-platform";

Expand All @@ -18,10 +22,17 @@ function buildProxyBin(target, release = true) {
return child_process.execSync(`cargo build --bin desktop_proxy ${releaseArg} ${targetArg}`, {stdio: 'inherit', cwd: path.join(__dirname, "proxy")});
}

if (!crossPlatform) {
console.log("Building native modules in debug mode for the native architecture");
buildNapiModule(false, false);
buildProxyBin(false, false);
if (!crossPlatform && !target) {
console.log(`Building native modules in ${mode} mode for the native architecture`);
buildNapiModule(false, mode === "release");
buildProxyBin(false, mode === "release");
return;
}

if (target) {
console.log(`Building for target: ${target} in ${mode} mode`);
buildNapiModule(target, mode === "release");
buildProxyBin(target, mode === "release");
return;
}

Expand All @@ -47,7 +58,8 @@ switch (process.platform) {

default:
targets = [
['x86_64-unknown-linux-musl', 'x64']
['x86_64-unknown-linux-musl', 'x64'],
['aarch64-unknown-linux-musl', 'arm64']
];

process.env["PKG_CONFIG_ALLOW_CROSS"] = "1";
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"pack:dir": "npm run clean:dist && electron-builder --dir -p never",
"pack:lin:flatpak": "npm run clean:dist && electron-builder --dir -p never && flatpak-builder --repo=build/.repo build/.flatpak ./resources/com.bitwarden.desktop.devel.yaml --install-deps-from=flathub --force-clean && flatpak build-bundle ./build/.repo/ ./dist/com.bitwarden.desktop.flatpak com.bitwarden.desktop",
"pack:lin": "npm run clean:dist && electron-builder --linux --x64 -p never && export SNAP_FILE=$(realpath ./dist/bitwarden_*.snap) && unsquashfs -d ./dist/tmp-snap/ $SNAP_FILE && mkdir -p ./dist/tmp-snap/meta/polkit/ && cp ./resources/com.bitwarden.desktop.policy ./dist/tmp-snap/meta/polkit/polkit.com.bitwarden.desktop.policy && rm $SNAP_FILE && snapcraft pack ./dist/tmp-snap/ && mv ./*.snap ./dist/ && rm -rf ./dist/tmp-snap/",
"pack:lin:arm64": "npm run clean:dist && electron-builder --dir -p never && tar -czvf ./dist/bitwarden_desktop_arm64.tar.gz -C ./dist/linux-arm64-unpacked/ .",
"pack:mac": "npm run clean:dist && electron-builder --mac --universal -p never",
"pack:mac:arm64": "npm run clean:dist && electron-builder --mac --arm64 -p never",
"pack:mac:mas": "npm run clean:dist && electron-builder --mac mas --universal -p never",
Expand All @@ -45,6 +46,7 @@
"pack:win:ci": "npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p never",
"dist:dir": "npm run build && npm run pack:dir",
"dist:lin": "npm run build && npm run pack:lin",
"dist:lin:arm64": "npm run build && npm run pack:lin:arm64",
"dist:mac": "npm run build && npm run pack:mac",
"dist:mac:mas": "npm run build && npm run pack:mac:mas",
"dist:mac:masdev": "npm run build && npm run pack:mac:masdev",
Expand Down
Loading