Build and package ARM releases

Change-type: minor
This commit is contained in:
ab77 2022-11-08 21:15:51 -08:00
parent 8cd6da1260
commit 81355b6a19
No known key found for this signature in database
GPG Key ID: D094F44E5E29445A
10 changed files with 22771 additions and 6374 deletions

View File

@ -15,7 +15,7 @@ inputs:
default: "accounts+apple@balena.io"
NODE_VERSION:
type: string
default: "14.x"
default: "16.19.0"
VERBOSE:
type: string
default: "true"
@ -41,10 +41,19 @@ runs:
node-version: ${{ inputs.NODE_VERSION }}
cache: npm
- name: Install yq
shell: bash --noprofile --norc -eo pipefail -x {0}
run: choco install yq
# FIXME: https://github.com/nodejs/node-gyp/issues/1371
# https://github.com/nodejs/node-gyp#command-options
- name: Install node-gyp
if: runner.os == 'Windows'
shell: bash
run: |
find "$(dirname $(which node))/.." -type f -name node-gyp.js \
| xargs -I{} node {} install
- name: Install package(s)
if: runner.os == 'Windows'
shell: bash
run: choco install yq
# FIXME: resinci-deploy is not actively maintained
# https://github.com/product-os/resinci-deploy
@ -56,7 +65,7 @@ runs:
path: resinci-deploy
- name: Build and install resinci-deploy
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
set -ea
@ -78,7 +87,7 @@ runs:
# https://docs.sentry.io/api/projects/create-a-new-client-key/
- name: Generate Sentry DSN
id: sentry
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
set -ea
@ -126,56 +135,74 @@ runs:
WINDOWS_CERTIFICATE: ${{ fromJSON(inputs.secrets).WINDOWS_SIGNING }}
WINDOWS_CERTIFICATE_PASSWORD: ${{ fromJSON(inputs.secrets).WINDOWS_SIGNING_PASSWORD }}
# ... or refactor (e.g.) https://github.com/samuelmeuli/action-electron-builder
# https://github.com/product-os/scripts/tree/master/electron
# https://github.com/product-os/scripts/tree/master/shared
# https://github.com/product-os/balena-concourse/blob/master/pipelines/github-events/template.yml
- name: Package release
id: package_release
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
runner_os="$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]')"
runner_arch="$(echo "${RUNNER_ARCH}" | tr '[:upper:]' '[:lower:]')"
ELECTRON_BUILDER_ARCHITECTURE="${runner_arch}"
APPLICATION_VERSION="$(jq -r '.version' package.json)"
ARCHITECTURE_FLAGS="--${ELECTRON_BUILDER_ARCHITECTURE}"
if [[ $runner_os =~ linux ]]; then
ELECTRON_BUILDER_OS='--linux'
TARGETS="$(yq e .linux.target[] electron-builder.yml)"
ELECTRON_BUILDER_OS=linux
elif [[ $runner_os =~ darwin|macos|osx ]]; then
CSC_KEY_PASSWORD=${{ fromJSON(inputs.secrets).APPLE_SIGNING_PASSWORD }}
CSC_KEYCHAIN=signing_temp
CSC_LINK=${{ fromJSON(inputs.secrets).APPLE_SIGNING }}
ELECTRON_BUILDER_OS='--mac'
TARGETS="$(yq e .mac.target[] electron-builder.yml)"
ELECTRON_BUILDER_OS=mac
elif [[ $runner_os =~ windows|win ]]; then
ARCHITECTURE_FLAGS="--ia32 ${ARCHITECTURE_FLAGS}"
CSC_KEY_PASSWORD=${{ fromJSON(inputs.secrets).WINDOWS_SIGNING_PASSWORD }}
CSC_LINK=${{ fromJSON(inputs.secrets).WINDOWS_SIGNING }}
ELECTRON_BUILDER_OS='--win'
TARGETS="$(yq e .win.target[] electron-builder.yml)"
ELECTRON_BUILDER_OS=win
else
exit 1
echo "${runner_os} is not supported"
false
fi
npm link electron-builder
for target in ${TARGETS}; do
electron-builder ${ELECTRON_BUILDER_OS} ${target} ${ARCHITECTURE_FLAGS} \
--c.extraMetadata.analytics.sentry.token='${{ steps.sentry.outputs.dsn }}' \
--c.extraMetadata.analytics.mixpanel.token='balena-etcher' \
--c.extraMetadata.packageType="${target}"
TARGETS="$(yq e '.build.[env(ELECTRON_BUILDER_OS)].target[].target' package.json)"
find dist -type f -maxdepth 1
for target in ${TARGETS}; do
archs="$(yq e '.build.[env(ELECTRON_BUILDER_OS)].target[] | select(.target == env(target)).arch[]' package.json)"
archs=(${archs})
for arch in ${archs[*]}; do
# (re)build|pack for all non-x64 architectures
if ! [[ "$arch" =~ x64 ]]; then
# FIXME: remove when Node.js win-arm64 support ships
# https://github.com/nodejs/build/issues/2450#issuecomment-1367786829
if [[ "$runner_os" =~ win ]] && [[ "$arch" =~ arm64 ]]; then
find "$(dirname $(which node))/.." -type f -name node-gyp.js \
| xargs -I{} node {} install \
--dist-url=https://unofficial-builds.nodejs.org/download/release
fi
npm ci
find node_modules -type d \( -name 'prebuilds' -o -name 'deps' \) \
| xargs -L1 -I{} find {} -type f
npm run build
fi
electron-builder "--${ELECTRON_BUILDER_OS}" "${target}" "--${arch}" \
--c.extraMetadata.analytics.sentry.token='${{ steps.sentry.outputs.dsn }}' \
--c.extraMetadata.analytics.mixpanel.token='balena-etcher' \
--c.extraMetadata.packageType="${target}"
find dist -type f -maxdepth 1
done
done
echo "version=${APPLICATION_VERSION}" >> $GITHUB_OUTPUT
@ -187,10 +214,13 @@ runs:
# https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks
# https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks#about-workflow-runs-from-public-forks
CSC_FOR_PULL_REQUEST: true
# https://www.electron.build/#debug
DEBUG: electron-builder
NPM_CONFIG_loglevel: verbose
# https://www.electron.build/auto-update.html#staged-rollouts
- name: Configure staged rollout(s)
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
set -ea

View File

@ -12,7 +12,7 @@ inputs:
# --- custom environment
NODE_VERSION:
type: string
default: "14.x"
default: "16.19.0"
VERBOSE:
type: string
default: "true"
@ -28,8 +28,17 @@ runs:
node-version: ${{ inputs.NODE_VERSION }}
cache: npm
# FIXME: https://github.com/nodejs/node-gyp/issues/1371
# https://github.com/nodejs/node-gyp#command-options
- name: Install node-gyp
if: runner.os == 'Windows'
shell: bash
run: |
find "$(dirname $(which node))/.." -type f -name node-gyp.js \
| xargs -I{} node {} install
- name: Test release
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
set -ea
@ -45,6 +54,7 @@ runs:
env:
# https://www.electronjs.org/docs/latest/api/environment-variables
ELECTRON_NO_ATTACH_CONSOLE: true
NPM_CONFIG_loglevel: verbose
- name: Compress custom source
shell: pwsh

View File

@ -1,110 +0,0 @@
# https://www.electron.build/configuration/configuration
appId: io.balena.etcher
copyright: Copyright 2016-2023 Balena Ltd
productName: balenaEtcher
afterPack: ./afterPack.js
afterSign: ./afterSignHook.js
asar: false
files:
- generated
- lib/shared/catalina-sudo/sudo-askpass.osascript-zh.js
- lib/shared/catalina-sudo/sudo-askpass.osascript-en.js
mac:
icon: assets/icon.icns
category: public.app-category.developer-tools
hardenedRuntime: true
entitlements: "entitlements.mac.plist"
entitlementsInherit: "entitlements.mac.plist"
artifactName: "${productName}-${version}.${ext}"
target:
- dmg
dmg:
background: assets/dmg/background.tiff
icon: assets/icon.icns
iconSize: 110
contents:
- x: 140
y: 225
- x: 415
y: 225
type: link
path: /Applications
window:
width: 540
height: 405
win:
icon: assets/icon.ico
target:
- zip
- nsis
- portable
nsis:
oneClick: true
runAfterFinish: true
installerIcon: assets/icon.ico
uninstallerIcon: assets/icon.ico
deleteAppDataOnUninstall: true
license: LICENSE
artifactName: "${productName}-Setup-${version}.${ext}"
portable:
artifactName: "${productName}-Portable-${version}.${ext}"
requestExecutionLevel: user
linux:
icon: assets/iconset
target:
- AppImage
- rpm
- deb
category: Utility
packageCategory: utils
executableName: balena-etcher
synopsis: balenaEtcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more.
appImage:
artifactName: ${productName}-${version}-${env.ELECTRON_BUILDER_ARCHITECTURE}.${ext}
deb:
priority: optional
compression: bzip2
depends:
- gconf-service
- gconf2
- libasound2
- libatk1.0-0
- libc6
- libcairo2
- libcups2
- libdbus-1-3
- libexpat1
- libfontconfig1
- libfreetype6
- libgbm1
- libgcc1
- libgconf-2-4
- libgdk-pixbuf2.0-0
- libglib2.0-0
- libgtk-3-0
- liblzma5
- libnotify4
- libnspr4
- libnss3
- libpango1.0-0 | libpango-1.0-0
- libstdc++6
- libx11-6
- libxcomposite1
- libxcursor1
- libxdamage1
- libxext6
- libxfixes3
- libxi6
- libxrandr2
- libxrender1
- libxss1
- libxtst6
- polkit-1-auth-agent | policykit-1-gnome | polkit-kde-1
afterInstall: "./after-install.tpl"
rpm:
depends:
- util-linux
protocols:
name: etcher
schemes:
- etcher

View File

@ -138,7 +138,8 @@ const translation = {
autoUpdate: 'Auto-updates enabled',
settings: 'Settings',
systemInformation: 'System Information',
trimExtPartitions: 'Trim unallocated space on raw images (in ext-type partitions)',
trimExtPartitions:
'Trim unallocated space on raw images (in ext-type partitions)',
},
menu: {
edit: 'Edit',

28649
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,24 +14,25 @@
},
"scripts": {
"build": "npm run webpack",
"flowzone-preinstall-linux": "sudo apt-get install -y xvfb libudev-dev && cat < electron-builder.yml | yq e .deb.depends[] - | xargs -L1 echo | sed 's/|//g' | xargs -L1 sudo apt-get --ignore-missing install || true",
"flowzone-preinstall-linux": "sudo apt-get install -y xvfb libudev-dev && cat < package.json | jq -r .build.deb.depends[] - | xargs -L1 echo | sed 's/|//g' | xargs -L1 sudo apt-get --ignore-missing install || true",
"flowzone-preinstall-macos": "true",
"flowzone-preinstall-windows": "true",
"flowzone-preinstall": "npm run flowzone-preinstall-linux",
"lint-css": "prettier --write lib/**/*.css",
"lint-ts": "balena-lint --fix --typescript typings lib tests scripts/clean-shrinkwrap.ts webpack.config.ts",
"lint": "npm run lint-ts && npm run lint-css",
"postinstall": "electron-rebuild -t prod,dev,optional",
"postinstall": "bash scripts/ci/postinstall.sh",
"preinstall": "bash scripts/ci/preinstall.sh",
"sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh",
"start": "./node_modules/.bin/electron .",
"test-macos": "npm run lint && npm run test-gui && npm run test-shared && npm run test-spectron && npm run sanity-checks",
"start": "node_modules/.bin/electron .",
"test-gui": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
"test-linux": "npm run lint && xvfb-run --auto-servernum npm run test-gui && xvfb-run --auto-servernum npm run test-shared && xvfb-run --auto-servernum npm run test-spectron && npm run sanity-checks",
"test-macos": "npm run lint && npm run test-gui && npm run test-shared && npm run test-spectron && npm run sanity-checks",
"test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts",
"test-spectron": "mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts tests/spectron/runner.spec.ts",
"test-windows": "npm run lint && npm run test-gui && npm run test-shared && npm run test-spectron && npm run sanity-checks",
"test": "echo npm run test-{linux,windows,macos}",
"watch": "webpack serve --no-optimization-minimize --config ./webpack.dev.config.ts",
"watch": "webpack serve --no-optimization-minimize --config webpack.dev.config.ts",
"webpack": "webpack"
},
"husky": {
@ -68,20 +69,20 @@
"@types/terser-webpack-plugin": "5.0.4",
"@types/tmp": "0.2.3",
"@types/webpack-node-externals": "2.5.3",
"aws4-axios": "2.4.9",
"aws4-axios": "2.4.6",
"chai": "4.3.7",
"copy-webpack-plugin": "7.0.0",
"css-loader": "5.2.7",
"d3": "4.13.0",
"debug": "4.3.4",
"electron": "^13.5.0",
"electron-builder": "^23.0.9",
"electron": "13.6.9",
"electron-builder": "23.6.0",
"electron-mocha": "9.3.3",
"electron-notarize": "1.2.2",
"electron-rebuild": "3.2.9",
"electron-updater": "5.3.0",
"esbuild-loader": "2.20.0",
"etcher-sdk": "^7.4.6",
"etcher-sdk": "7.4.7-build-ab77-operational-6f10344d887bcf306b3bf897a5451666f6590ae9-1",
"file-loader": "6.2.0",
"husky": "4.3.8",
"i18next": "21.10.0",
@ -94,6 +95,7 @@
"node-ipc": "9.2.1",
"omit-deep-lodash": "1.1.7",
"outdent": "0.8.0",
"patch-package": "^6.5.1",
"path-is-inside": "1.0.2",
"pnp-webpack-plugin": "1.7.0",
"pretty-bytes": "5.6.0",
@ -123,9 +125,182 @@
"webpack-dev-server": "4.11.1"
},
"engines": {
"node": ">=14 < 16"
"node": "16"
},
"build": {
"appId": "io.balena.etcher",
"copyright": "Copyright 2016-2023 Balena Ltd",
"productName": "balenaEtcher",
"afterPack": "./afterPack.js",
"afterSign": "./afterSignHook.js",
"asar": false,
"files": [
"generated",
"lib/shared/catalina-sudo/sudo-askpass.osascript.js"
],
"mac": {
"icon": "assets/icon.icns",
"category": "public.app-category.developer-tools",
"hardenedRuntime": true,
"entitlements": "entitlements.mac.plist",
"entitlementsInherit": "entitlements.mac.plist",
"target": [
{
"target": "dmg",
"arch": [
"x64",
"arm64"
]
}
]
},
"dmg": {
"artifactName": "${productName}-${version}-${arch}.${ext}",
"background": "assets/dmg/background.tiff",
"icon": "assets/icon.icns",
"iconSize": 110,
"contents": [
{
"x": 140,
"y": 225
},
{
"x": 415,
"y": 225,
"type": "link",
"path": "/Applications"
}
],
"window": {
"width": 540,
"height": 405
}
},
"win": {
"icon": "assets/icon.ico",
"target": [
{
"target": "nsis",
"arch": [
"x64",
"arm64"
]
},
{
"target": "portable",
"arch": [
"x64",
"arm64"
]
}
]
},
"nsis": {
"oneClick": true,
"runAfterFinish": true,
"installerIcon": "assets/icon.ico",
"uninstallerIcon": "assets/icon.ico",
"deleteAppDataOnUninstall": true,
"license": "LICENSE",
"artifactName": "${productName}-Setup-${version}-${arch}.${ext}"
},
"portable": {
"artifactName": "${productName}-Portable-${version}-${arch}.${ext}",
"requestExecutionLevel": "user"
},
"linux": {
"icon": "assets/iconset",
"target": [
{
"target": "AppImage",
"arch": [
"x64",
"arm64",
"armv7l"
]
},
{
"target": "rpm",
"arch": [
"x64",
"arm64",
"armv7l"
]
},
{
"target": "deb",
"arch": [
"x64",
"arm64",
"armv7l"
]
}
],
"category": "Utility",
"packageCategory": "utils",
"executableName": "balena-etcher",
"synopsis": "balenaEtcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more."
},
"appImage": {
"artifactName": "${productName}-${version}-${arch}.${ext}"
},
"deb": {
"priority": "optional",
"compression": "bzip2",
"depends": [
"gconf-service",
"gconf2",
"libasound2",
"libatk1.0-0",
"libc6",
"libcairo2",
"libcups2",
"libdbus-1-3",
"libexpat1",
"libfontconfig1",
"libfreetype6",
"libgbm1",
"libgcc1",
"libgconf-2-4",
"libgdk-pixbuf2.0-0",
"libglib2.0-0",
"libgtk-3-0",
"liblzma5",
"libnotify4",
"libnspr4",
"libnss3",
"libpango1.0-0 | libpango-1.0-0",
"libstdc++6",
"libx11-6",
"libxcomposite1",
"libxcursor1",
"libxdamage1",
"libxext6",
"libxfixes3",
"libxi6",
"libxrandr2",
"libxrender1",
"libxss1",
"libxtst6",
"polkit-1-auth-agent | policykit-1-gnome | polkit-kde-1"
],
"afterInstall": "./after-install.tpl",
"artifactName": "${productName}-${version}-${arch}.${ext}"
},
"rpm": {
"depends": [
"util-linux"
],
"artifactName": "${productName}-${version}-${arch}.${ext}"
},
"protocols": {
"name": "etcher",
"schemes": [
"etcher"
]
}
},
"versionist": {
"publishedAt": "2023-01-02T20:55:58.804Z"
"publishedAt": "2022-12-05T21:38:42.561Z"
}
}

View File

@ -0,0 +1,47 @@
diff --git a/node_modules/lzma-native/binding.gyp b/node_modules/lzma-native/binding.gyp
index 8bcda26..3d66890 100644
--- a/node_modules/lzma-native/binding.gyp
+++ b/node_modules/lzma-native/binding.gyp
@@ -38,8 +38,10 @@
"conditions": [
[ 'target_arch=="x64"', {
"library_dirs" : [ "<(module_root_dir)\\deps\\bin_x86-64" ]
- }, {
+ }, 'target_arch=="ia32"', {
"library_dirs" : [ "<(module_root_dir)\\deps\\bin_i686" ]
+ }, {
+ "library_dirs" : [ "<(module_root_dir)\\deps\\bin_ARM64" ]
} ]
]
}
@@ -69,11 +71,16 @@
"arch_lib_path" : 'bin_x86-64',
"arch_lib_code" : 'x64'
}
- }, {
+ }, 'target_arch=="ia32"', {
'variables': {
"arch_lib_path" : 'bin_i686',
"arch_lib_code" : 'ix86'
}
+ },{
+ 'variables': {
+ "arch_lib_path" : 'bin_ARM64',
+ "arch_lib_code" : 'ARM64'
+ }
} ]
],
"actions" : [
diff --git a/node_modules/lzma-native/package.json b/node_modules/lzma-native/package.json
index 3264e55..f18ea42 100644
--- a/node_modules/lzma-native/package.json
+++ b/node_modules/lzma-native/package.json
@@ -37,7 +37,7 @@
"prepack": "[ $(ls prebuilds | wc -l) = '6' ] || (echo 'Some prebuilds are missing'; exit 1)",
"test": "mocha --expose-gc -s 1000 -t 15000",
"prepare": "npm run prepare-win32 || true",
- "prepare-win32": "cd deps && 7z x -y xz-5.2.3-windows.7z bin_i686/liblzma.dll bin_x86-64/liblzma.dll include doc/liblzma.def",
+ "prepare-win32": "cd deps && 7z x -y xz-5.2.3-windows.7z bin_i686/liblzma.dll bin_x86-64/liblzma.dll bin_ARM64/liblzma.dll include doc/liblzma.def",
"jshint": "jshint ."
},
"gypfile": true,

30
scripts/ci/postinstall.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -ea
[[ "$VERBOSE" =~ on|On|Yes|yes|true|True ]] && set -x
# use specified or fallback to platform architecture
arch="${arch:-$(node -e 'console.log(os.arch())')}"
# FIXME: remove when lzma-native ships with win-arm64 suport
# https://github.com/addaleax/lzma-native/issues/132
pushd node_modules/lzma-native
# https://docs.npmjs.com/cli/v9/using-npm/config#environment-variables
NPM_CONFIG_arch="${arch}" \
NPM_CONFIG_target_arch="${NPM_CONFIG_arch}" npm i
# https://github.com/prebuild/prebuildify#options
# https://www.npmjs.com/package/node-gyp-build
PREBUILD_ARCH="${NPM_CONFIG_arch}" npm run prebuild
popd
# FIXME: (re)build for the latest version of electron, since v13.x uses ancient node-gyp
# https://releases.electronjs.org/releases/stable
electron_version="${ELECTRON_VERSION:-$(npm view electron --json | jq -r '.version')}"
# https://github.com/electron/rebuild#cli-arguments
electron-rebuild \
--types prod,dev,optional \
--arch "${arch}" \
--version "${electron_version}"

9
scripts/ci/preinstall.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -ea
[[ "$VERBOSE" =~ on|On|Yes|yes|true|True ]] && set -x
# FIXME: remove when lzma-native ships with win-arm64 suport
# https://github.com/addaleax/lzma-native/issues/132
find patches -type f | xargs cat && npx patch-package

View File

@ -176,7 +176,8 @@ function replace(test: RegExp, ...replacements: ReplacementRule[]) {
loader: 'string-replace-loader',
// Handle windows path separators
test: slashOrAntislash(test),
options: { multiple: replacements.map((r) => ({ ...r, strict: true })) },
// https://github.com/Va1/string-replace-loader#strict-mode-replacement
options: { multiple: replacements.map((r) => ({ ...r, strict: false })) },
};
}
@ -190,6 +191,7 @@ function fetchWasm(...where: string[]) {
electron = require('electron');
} catch {
}
// FIXME: throws an error with string-replace-loader { strict: true }
function appPath() {
return Path.isAbsolute(__dirname) ?
__dirname :