Skip to content

Commit

Permalink
Build desktop-native in alpine container
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Dec 20, 2024
1 parent 69d42a7 commit e7ef6e9
Showing 1 changed file with 71 additions and 59 deletions.
130 changes: 71 additions & 59 deletions .github/workflows/build-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ on:
pull_request_target:
types: [opened, synchronize]
branches-ignore:
- 'l10n_master'
- 'cf-pages'
- "l10n_master"
- "cf-pages"
paths:
- 'apps/desktop/**'
- 'libs/**'
- '*'
- '!*.md'
- '!*.txt'
- '.github/workflows/build-desktop.yml'
- "apps/desktop/**"
- "libs/**"
- "*"
- "!*.md"
- "!*.txt"
- ".github/workflows/build-desktop.yml"
push:
branches:
- 'main'
- 'rc'
- 'hotfix-rc-desktop'
- "main"
- "rc"
- "hotfix-rc-desktop"
paths:
- 'apps/desktop/**'
- 'libs/**'
- '*'
- '!*.md'
- '!*.txt'
- '.github/workflows/build-desktop.yml'
- "apps/desktop/**"
- "libs/**"
- "*"
- "!*.md"
- "!*.txt"
- ".github/workflows/build-desktop.yml"
workflow_dispatch:
inputs:
sdk_branch:
Expand Down Expand Up @@ -138,6 +138,42 @@ jobs:
NODE_VERSION=${NODE_NVMRC/v/''}
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
linux-desktop-native:
name: Desktop Native Linux Build
runs-on: ubuntu-24.04
container:
image: alpine:3.20
needs: setup
defaults:
run:
working-directory: apps/desktop/desktop_native
steps:
- name: Check out repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up environment
run: |
apk add --no-cache \
build-base \
rustup \
npm
echo 1 | rustup-init --default-toolchain stable --target x86_64-unknown-linux-musl
- name: NPM install
run: cd ../../../ && npm install
- name: Build Native Module
env:
PKG_CONFIG_ALL_STATIC: true
TARGET: musl
run: |
source $HOME/.cargo/env
node build.js release
- name: Upload Native Module
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: desktop_napi-linux-x86_64-unknown-linux-musl
path: apps/desktop/desktop_native/napi/desktop_napi.linux-x64-musl.node

linux:
name: Linux Build
# Note, before updating the ubuntu version of the workflow, ensure the snap base image
Expand All @@ -146,7 +182,7 @@ jobs:
# We are currently running on 20.04 until the Ubuntu 24.04 release is available, as moving
# to 22.04 now breaks users who are on 20.04 due to mismatched GLIBC versions.
runs-on: ubuntu-20.04
needs: setup
needs: linux-desktop-native
env:
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
Expand All @@ -163,14 +199,14 @@ jobs:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
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
sudo apt-get -y install pkg-config libxss-dev rpm flatpak flatpak-builder
- name: Set up Snap
run: sudo snap install snapcraft --classic
Expand Down Expand Up @@ -206,27 +242,11 @@ jobs:
ls -l ../
npm link ../sdk-internal
- name: Cache Native Module
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache
- name: Download napi module
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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 }}-${{ 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 x86_64-unknown-linux-musl
node build.js cross-platform
name: desktop_napi-linux-x86_64-unknown-linux-musl
path: apps/desktop/desktop_native/napi/desktop_napi.linux-x64-musl.node

- name: Build application
run: npm run dist:lin
Expand Down Expand Up @@ -286,7 +306,6 @@ jobs:
path: apps/desktop/dist/com.bitwarden.desktop.flatpak
if-no-files-found: error


windows:
name: Windows Build
runs-on: windows-2022
Expand All @@ -309,8 +328,8 @@ jobs:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}

- name: Install AST
Expand Down Expand Up @@ -518,7 +537,6 @@ jobs:
path: apps/desktop/dist/nsis-web/${{ needs.setup.outputs.release_channel }}.yml
if-no-files-found: error


macos-build:
name: MacOS Build
runs-on: macos-13
Expand All @@ -540,8 +558,8 @@ jobs:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}

- name: Set up Node-gyp
Expand Down Expand Up @@ -697,14 +715,12 @@ jobs:
- name: Build application (dev)
run: npm run build


browser-build:
name: Browser Build
needs: setup
uses: ./.github/workflows/build-browser.yml
secrets: inherit


macos-package-github:
name: MacOS Package GitHub Release Assets
runs-on: macos-13
Expand All @@ -728,8 +744,8 @@ jobs:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}

- name: Set up Node-gyp
Expand Down Expand Up @@ -945,7 +961,6 @@ jobs:
path: apps/desktop/dist/${{ needs.setup.outputs.release_channel }}-mac.yml
if-no-files-found: error


macos-package-mas:
name: MacOS Package Prod Release Asset
runs-on: macos-13
Expand All @@ -969,8 +984,8 @@ jobs:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}

- name: Set up Node-gyp
Expand Down Expand Up @@ -1212,7 +1227,6 @@ jobs:
SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secret.outputs.slack-bot-token }}
BUILD_NUMBER: ${{ needs.setup.outputs.build_number }}


macos-package-dev:
name: MacOS Package Dev Release Asset
runs-on: macos-13
Expand All @@ -1236,8 +1250,8 @@ jobs:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}

- name: Set up Node-gyp
Expand Down Expand Up @@ -1430,7 +1444,6 @@ jobs:
path: apps/desktop/dist/mas-dev-universal/Bitwarden-${{ env._PACKAGE_VERSION }}-masdev-universal.zip
if-no-files-found: error


crowdin-push:
name: Crowdin Push
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -1470,7 +1483,6 @@ jobs:
upload_sources: true
upload_translations: false


check-failures:
name: Check for failures
if: always()
Expand Down

0 comments on commit e7ef6e9

Please sign in to comment.