Skip to content

Commit

Permalink
sadds
Browse files Browse the repository at this point in the history
  • Loading branch information
dfunckt committed Nov 15, 2023
1 parent e145aa7 commit 6535dcd
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 64 deletions.
54 changes: 6 additions & 48 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ runs:

- name: Extract custom source artifact
if: runner.os != 'Windows'
shell: pwsh
shell: bash
working-directory: .
run: tar -xf ${{ runner.temp }}/custom.tgz

Expand All @@ -47,11 +47,8 @@ runs:

- name: Install host dependencies
if: runner.os == 'Linux'
shell: bash --noprofile --norc -eo pipefail -x {0}
run: |
set -ea
sudo apt-get update
sudo apt-get install -y --no-install-recommends fakeroot dpkg rpm
shell: bash
run: sudo apt-get install -y --no-install-recommends fakeroot dpkg rpm

- name: Install host dependencies
if: runner.os == 'macOS'
Expand All @@ -66,7 +63,7 @@ runs:
# https://dev.to/rwwagner90/signing-electron-apps-with-github-actions-4cof
- name: Import Apple code signing certificate
if: runner.os == 'macOS'
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
KEY_CHAIN=build.keychain
CERTIFICATE_P12=certificate.p12
Expand Down Expand Up @@ -102,47 +99,8 @@ runs:
encodedString: ${{ fromJSON(inputs.secrets).WINDOWS_SIGNING }}

- name: Package release
id: package_release
shell: bash --noprofile --norc -eo pipefail -x {0}
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
runner_os="$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]')"
APPLICATION_VERSION="$(jq -r '.version' package.json)"
if [[ $runner_os =~ linux ]]; then
BUILD_ARCH=x64
npm run make -- --arch="${BUILD_ARCH}"
elif [[ $runner_os =~ darwin|macos|osx ]]; then
BUILD_ARCH=x64,arm64
npm run make -- --arch="${BUILD_ARCH}"
elif [[ $runner_os =~ windows|win ]]; then
BUILD_ARCH=ia32,x64
npm run make-debug-win -- --arch="${BUILD_ARCH}"
else
echo "ERROR: unexpected runner OS: ${runner_os}"
exit 1
fi
echo "version=${APPLICATION_VERSION}" >> $GITHUB_OUTPUT
# collect all artifacts from subdirectories under a common top-level directory
mkdir -p dist
find ./out/make -type f \( \
-iname "*.zip" -o \
-iname "*.dmg" -o \
-iname "*.rpm" -o \
-iname "*.deb" -o \
-iname "*.AppImage" -o \
-iname "*Setup.exe" \
\) -ls -exec cp '{}' dist/ \;
shell: bash
run: ./build/make-all.sh
env:
# ensure we sign the artifacts
NODE_ENV: production
Expand Down
19 changes: 8 additions & 11 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ runs:

- name: Install host dependencies
if: runner.os == 'Linux'
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: bash
run: |
set -ea
sudo apt-get update
sudo apt-get install -y --no-install-recommends xvfb libudev-dev
cat < package.json | jq -r '.hostDependencies[][]' - | \
xargs -L1 echo | sed 's/|//g' | xargs -L1 \
Expand All @@ -48,21 +46,20 @@ runs:
with:
python-version: '3.11'

- name: Install project dependencies
shell: bash
run: npm ci

- name: Test release
shell: bash --noprofile --norc -eo pipefail -x {0}
run: |
set -ea
runner_os="$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]')"
npm ci
npm run package
npm run test-${runner_os}
shell: bash
run: ./build/test-all.sh
env:
# https://www.electronjs.org/docs/latest/api/environment-variables
ELECTRON_NO_ATTACH_CONSOLE: 'true'

- name: Compress custom source
if: runner.os != 'Windows'
shell: pwsh
shell: bash
run: tar -acf ${{ runner.temp }}/custom.tgz .

- name: Compress custom source
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ out/

# ---- Do not modify entries above this line ----

# Build artifacts
dist/

# Certificates
*.spc
*.pvk
Expand Down
50 changes: 50 additions & 0 deletions build/make-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

set -ea

if [[ "$VERBOSE" =~ 1|on|On|Yes|yes|true|True ]]; then
set +x
export DEBUG='electron-forge:*,electron-packager,electron-rebuild'
fi

case "$(uname -s)" in
"Linux")
PLATFORM=Linux
TARGET_ARCH=x64
SHA256SUM_BIN=sha256sum
npm run make -- --arch="$TARGET_ARCH"
;;
"Darwin")
PLATFORM=Darwin
TARGET_ARCH=x64,arm64
SHA256SUM_BIN='shasum -a 256'
npm run make -- --arch="$TARGET_ARCH"
;;
"Windows"*|"MINGW"*|"MSYS"*)
PLATFORM=Windows
TARGET_ARCH=ia32,x64
SHA256SUM_BIN=sha256sum
powershell -c npm run make -- --arch="$TARGET_ARCH"
;;
esac

# collect all artifacts from subdirectories under a common top-level directory
if [[ -d dist ]]; then
rm -rf dist/
fi
mkdir -p dist
find ./out/make -type f \( \
-iname "*.zip" -o \
-iname "*.dmg" -o \
-iname "*.rpm" -o \
-iname "*.deb" -o \
-iname "*.AppImage" -o \
-iname "*Setup.exe" \
\) -ls -exec cp '{}' dist/ \;

if [[ $PLATFORM != 'Windows' ]]; then
# Compute and save digests.
# Sorry, cannot be bothered with figuring how to do this on Windows.
cd dist/
${SHA256SUM_BIN} *.* >SHA256SUMS.${PLATFORM}.txt
fi
23 changes: 23 additions & 0 deletions build/test-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -ea

if [[ "$VERBOSE" =~ 1|on|On|Yes|yes|true|True ]]; then
set +x
export DEBUG='electron-forge:*,electron-packager,electron-rebuild'
fi

npm run package
npm run lint

case "$(uname -s)" in
"Linux")
xvfb-run --auto-servernum npm run test-gui && xvfb-run --auto-servernum npm run test-shared
;;
"Darwin")
npm run test-gui && npm run test-shared
;;
"Windows"*|"MINGW"*|"MSYS"*)
npm run test-gui && npm run test-shared
;;
esac
4 changes: 3 additions & 1 deletion forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MakerDMG } from '@electron-forge/maker-dmg';
import { MakerAppImage } from '@reforged/maker-appimage';
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
import { ResourcePlugin } from 'electron-forge-resource-plugin';
// import { ResourcePlugin } from 'electron-forge-resource-plugin';

import { mainConfig, rendererConfig } from './webpack.config';

Expand Down Expand Up @@ -134,6 +134,7 @@ const config: ForgeConfig = {
],
},
}),
/*
new ResourcePlugin({
env: 'ETCHER_UTIL_BIN_PATH',
path: `out/sidecar/bin/etcher-util${process.platform === 'win32' ? '.exe' : ''}`,
Expand All @@ -142,6 +143,7 @@ const config: ForgeConfig = {
sources: './lib/util/',
},
}),
*/
],
};

Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
"lint": "npm run lint-ts && npm run lint-css",
"test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
"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-windows": "npm run lint && npm run test-gui && npm run test-shared",
"test-macos": "npm run lint && npm run test-gui && npm run test-shared",
"test-linux": "npm run lint && xvfb-run --auto-servernum npm run test-gui && xvfb-run --auto-servernum npm run test-shared",
"test": "echo npm run test-{linux,windows,macos}",
"test": "build/test-all.sh",
"package": "electron-forge package",
"start": "electron-forge start",
"make": "electron-forge make"
Expand Down

0 comments on commit 6535dcd

Please sign in to comment.