2022-12-13 15:12:40 +01:00
|
|
|
# This workflow relies on actions/cache to store the hak dependency artifacts as they take a long time to build
|
|
|
|
# Due to this extra care must be taken to only ever run all build_* scripts against the same branch to ensure
|
|
|
|
# the correct cache scoping, and additional care must be taken to not run untrusted actions on the develop branch.
|
2022-11-11 16:15:21 +01:00
|
|
|
on:
|
2022-12-15 12:00:58 +01:00
|
|
|
workflow_call:
|
2023-02-22 14:51:19 +01:00
|
|
|
secrets:
|
|
|
|
ESIGNER_USER_NAME:
|
|
|
|
required: false
|
|
|
|
ESIGNER_USER_PASSWORD:
|
|
|
|
required: false
|
|
|
|
ESIGNER_USER_TOTP:
|
|
|
|
required: false
|
2022-12-15 12:00:58 +01:00
|
|
|
inputs:
|
|
|
|
arch:
|
|
|
|
type: string
|
|
|
|
required: true
|
2023-03-22 10:41:51 +01:00
|
|
|
description: "The architecture to build for, one of 'x64' | 'x86' | 'arm64'"
|
2023-02-22 14:51:19 +01:00
|
|
|
version:
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
description: "Version string to override the one in package.json, used for non-release builds"
|
|
|
|
sign:
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
description: "Whether to sign & notarise the build, requires 'packages.element.io' environment"
|
|
|
|
deploy-mode:
|
2023-03-31 12:00:30 +02:00
|
|
|
type: boolean
|
2023-02-22 14:51:19 +01:00
|
|
|
required: false
|
|
|
|
description: "Whether to arrange artifacts in the arrangement needed for deployment, skipping unrelated ones"
|
2022-11-11 16:15:21 +01:00
|
|
|
jobs:
|
2022-12-15 12:00:58 +01:00
|
|
|
build:
|
|
|
|
runs-on: windows-latest
|
2023-02-22 14:51:19 +01:00
|
|
|
environment: ${{ inputs.sign && 'packages.element.io' || '' }}
|
2023-03-06 09:56:49 +01:00
|
|
|
env:
|
|
|
|
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.22000.0/x86/signtool.exe"
|
2022-12-15 12:00:58 +01:00
|
|
|
steps:
|
2023-05-09 13:01:35 +02:00
|
|
|
- uses: kanga333/variable-mapper@3681b75f5c6c00162721168fb91ab74925eaebcb
|
2022-12-15 12:00:58 +01:00
|
|
|
id: config
|
|
|
|
with:
|
|
|
|
key: "${{ inputs.arch }}"
|
|
|
|
export_to: output
|
|
|
|
map: |
|
|
|
|
{
|
|
|
|
"x64": {
|
2023-02-27 11:47:40 +01:00
|
|
|
"target": "x86_64-pc-windows-msvc",
|
2023-02-27 11:52:25 +01:00
|
|
|
"dir": "x64"
|
2022-12-15 12:00:58 +01:00
|
|
|
},
|
2023-03-22 10:41:51 +01:00
|
|
|
"arm64": {
|
|
|
|
"target": "aarch64-pc-windows-msvc",
|
|
|
|
"build-args": "--arm64",
|
|
|
|
"arch": "amd64_arm64",
|
|
|
|
"dir": "arm64"
|
|
|
|
},
|
2022-12-15 12:00:58 +01:00
|
|
|
"x86": {
|
|
|
|
"target": "i686-pc-windows-msvc",
|
2023-02-27 11:47:40 +01:00
|
|
|
"build-args": "--ia32",
|
2023-02-27 11:52:25 +01:00
|
|
|
"dir": "ia32"
|
2022-12-15 12:00:58 +01:00
|
|
|
}
|
|
|
|
}
|
2022-11-14 12:09:07 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- uses: actions/checkout@v3
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2023-12-20 11:01:54 +01:00
|
|
|
- uses: actions/download-artifact@v3
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
|
|
|
name: webapp
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Cache .hak
|
|
|
|
id: cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
2023-04-26 16:04:17 +02:00
|
|
|
key: ${{ runner.os }}-${{ inputs.arch }}-${{ hashFiles('hakHash', 'electronVersion') }}
|
2022-12-15 12:00:58 +01:00
|
|
|
path: |
|
|
|
|
./.hak
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Set up build tools
|
2023-05-09 13:01:35 +02:00
|
|
|
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
2023-03-22 10:41:51 +01:00
|
|
|
arch: ${{ steps.config.outputs.arch || inputs.arch }}
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
# ActiveTCL package on choco is from 2015,
|
|
|
|
# this one is newer but includes more than we need
|
|
|
|
- name: Choco install tclsh
|
2023-02-22 14:51:19 +01:00
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2022-12-15 12:00:58 +01:00
|
|
|
shell: pwsh
|
|
|
|
run: |
|
|
|
|
choco install -y magicsplat-tcl-tk --no-progress
|
|
|
|
echo "${HOME}/AppData/Local/Apps/Tcl86/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Choco install NetWide Assembler
|
2023-02-22 14:51:19 +01:00
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2022-12-15 12:00:58 +01:00
|
|
|
shell: pwsh
|
|
|
|
run: |
|
|
|
|
choco install -y nasm --no-progress
|
|
|
|
echo "C:/Program Files/NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Install Rust
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2023-08-02 15:34:38 +02:00
|
|
|
run: |
|
|
|
|
rustup toolchain install stable --profile minimal --no-self-update
|
|
|
|
rustup default stable
|
|
|
|
rustup target add ${{ steps.config.outputs.target }}
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
cache: "yarn"
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
# Does not need branch matching as only analyses this layer
|
|
|
|
- name: Install Deps
|
2023-03-31 17:17:43 +02:00
|
|
|
run: "yarn install --frozen-lockfile"
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Build Natives
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
refreshenv
|
|
|
|
yarn build:native --target ${{ steps.config.outputs.target }}
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2023-02-22 14:51:19 +01:00
|
|
|
- name: Install and configure eSigner CKA
|
|
|
|
id: esigner
|
|
|
|
if: inputs.sign
|
|
|
|
run: |
|
|
|
|
Set-StrictMode -Version 'Latest'
|
|
|
|
|
|
|
|
# Download
|
|
|
|
Invoke-WebRequest -OutFile eSigner_CKA.exe "https://packages.element.io/tools/SSL.COM%20eSigner%20CKA_1.0.4-build-20230221_signed.exe"
|
|
|
|
|
|
|
|
# Install
|
|
|
|
New-Item -ItemType Directory -Force -Path "$env:INSTALL_DIR"
|
|
|
|
./eSigner_CKA.exe /CURRENTUSER /VERYSILENT /SUPPRESSMSGBOXES /DIR="${{ env.INSTALL_DIR }}" | Out-Null
|
|
|
|
|
|
|
|
# Disable logger
|
|
|
|
$LogConfig = Get-Content -Path ${{ env.INSTALL_DIR }}/log4net.config
|
|
|
|
$LogConfig[0] = '<log4net threshold="OFF">'
|
|
|
|
$LogConfig | Set-Content -Path ${{ env.INSTALL_DIR }}/log4net.config
|
|
|
|
|
|
|
|
# Configure
|
2023-03-20 09:17:34 +01:00
|
|
|
${{ env.INSTALL_DIR }}/eSignerCKATool.exe config -mode product -user "${{ secrets.ESIGNER_USER_NAME }}" -pass "${{ secrets.ESIGNER_USER_PASSWORD }}" -totp "${{ secrets.ESIGNER_USER_TOTP }}" -key "${{ env.MASTER_KEY_FILE }}" -r
|
2023-02-22 14:51:19 +01:00
|
|
|
${{ env.INSTALL_DIR }}/eSignerCKATool.exe unload
|
|
|
|
${{ env.INSTALL_DIR }}/eSignerCKATool.exe load
|
|
|
|
|
|
|
|
# Find certificate
|
|
|
|
$CodeSigningCert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
|
|
|
|
echo Certificate: $CodeSigningCert
|
|
|
|
|
|
|
|
# Extract thumbprint and subject name
|
|
|
|
$Thumbprint = $CodeSigningCert.Thumbprint
|
|
|
|
$SubjectName = ($CodeSigningCert.Subject -replace ", ?", "`n" | ConvertFrom-StringData).CN
|
|
|
|
echo "config-args=--signtool-thumbprint '$Thumbprint' --signtool-subject-name '$SubjectName'" >> $env:GITHUB_OUTPUT
|
|
|
|
env:
|
|
|
|
INSTALL_DIR: C:\Users\runneradmin\eSignerCKA
|
|
|
|
MASTER_KEY_FILE: C:\Users\runneradmin\eSignerCKA\master.key
|
|
|
|
|
|
|
|
- name: "[Nightly] Resolve version"
|
|
|
|
id: nightly
|
|
|
|
if: inputs.version != ''
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "config-args=--nightly '${{ inputs.version }}'" >> $GITHUB_OUTPUT
|
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Build App
|
2023-02-22 14:51:19 +01:00
|
|
|
run: |
|
|
|
|
yarn ts-node scripts/generate-builder-config.ts ${{ steps.nightly.outputs.config-args }} ${{ steps.esigner.outputs.config-args }}
|
|
|
|
yarn build --publish never -w --config electron-builder.json ${{ steps.config.outputs.build-args }}
|
2023-03-06 09:56:49 +01:00
|
|
|
|
|
|
|
- name: Check app was signed successfully
|
|
|
|
if: inputs.sign != ''
|
|
|
|
run: |
|
|
|
|
. "$env:SIGNTOOL_PATH" verify /pa (get-item ./dist/squirrel-windows*/*.exe)
|
2023-02-22 14:51:19 +01:00
|
|
|
|
|
|
|
- name: Prepare artifacts for deployment
|
|
|
|
if: inputs.deploy-mode
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
mv dist _dist
|
2023-02-27 11:47:40 +01:00
|
|
|
mkdir -p "dist/install/win32/$DIR/msi" "dist/update/win32/$DIR"
|
|
|
|
mv _dist/squirrel-windows*/*.exe "dist/install/win32/$DIR"
|
|
|
|
mv _dist/squirrel-windows*/*.nupkg "dist/update/win32/$DIR/"
|
|
|
|
mv _dist/squirrel-windows*/RELEASES "dist/update/win32/$DIR/"
|
|
|
|
# mv _dist/*.msi "dist/install/win32/$DIR/msi/"
|
|
|
|
env:
|
|
|
|
DIR: ${{ steps.config.outputs.dir }}
|
2023-02-22 14:51:19 +01:00
|
|
|
|
|
|
|
# We don't wish to store the installer for every nightly ever, so we only keep the latest
|
|
|
|
- name: "[Nightly] Strip version from installer file"
|
|
|
|
if: inputs.deploy-mode && inputs.version != ''
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2023-02-27 11:47:40 +01:00
|
|
|
mv dist/install/win32/$DIR/*.exe "dist/install/win32/$DIR/Element Nightly Setup.exe"
|
|
|
|
# mv dist/install/win32/$DIR/msi/*.msi "dist/install/win32/$DIR/msi/Element Nightly Setup.msi"
|
|
|
|
env:
|
|
|
|
DIR: ${{ steps.config.outputs.dir }}
|
2023-02-22 14:51:19 +01:00
|
|
|
|
|
|
|
- name: "[Release] Prepare release latest symlink"
|
|
|
|
if: inputs.deploy-mode && inputs.version == ''
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
ln -s "$(find . -type f -iname "*.exe" | xargs -0 -n1 -- basename)" "Element Setup.exe"
|
2023-02-27 11:47:40 +01:00
|
|
|
working-directory: "dist/install/win32/${{ steps.config.outputs.dir }}"
|
2022-11-11 16:15:21 +01:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Upload Artifacts
|
2023-12-20 11:01:54 +01:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
2023-02-22 14:51:19 +01:00
|
|
|
name: ${{ inputs.deploy-mode && 'packages.element.io' || format('win-{0}', inputs.arch) }}
|
2022-12-15 12:00:58 +01:00
|
|
|
path: dist
|
|
|
|
retention-days: 1
|