Skip to content
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

Build and package ARM releases #3896

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 46 additions & 29 deletions .github/actions/publish/action.yml
Expand Up @@ -15,10 +15,10 @@ inputs:
default: "accounts+apple@balena.io"
NODE_VERSION:
type: string
default: "14.x"
default: "16.x"
VERBOSE:
type: string
default: "true"
default: "false"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
Expand All @@ -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
Expand All @@ -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

Expand All @@ -78,12 +87,10 @@ 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

[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x

branch="$(echo '${{ github.event.pull_request.head.ref }}' | sed 's/[^[:alnum:]]/-/g')"

stdout="$(resinci-deploy store sentry \
Expand All @@ -93,6 +100,7 @@ runs:
--org="$(yq e '.sentry.org' repo.yml)" \
--type="$(yq e '.sentry.type' repo.yml)")"

echo "::add-mask::${stdout}"
echo "dsn=$(echo "${stdout}" | tail -n 1)" >> $GITHUB_OUTPUT

env:
Expand Down Expand Up @@ -126,56 +134,65 @@ 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
npm ci
npm run build
fi

find node_modules -type d \( -name 'prebuilds' -o -name 'deps' \) \
| xargs -L1 -I{} find {} -type f

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
Expand All @@ -190,7 +207,7 @@ runs:

# 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

Expand Down
15 changes: 12 additions & 3 deletions .github/actions/test/action.yml
Expand Up @@ -12,10 +12,10 @@ inputs:
# --- custom environment
NODE_VERSION:
type: string
default: "14.x"
default: "16.x"
VERBOSE:
type: string
default: "true"
default: "false"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
Expand All @@ -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

Expand Down
110 changes: 0 additions & 110 deletions electron-builder.yml

This file was deleted.

3 changes: 2 additions & 1 deletion lib/gui/app/i18n/en.ts
Expand Up @@ -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',
Expand Down