2022-12-13 14:12:40 +00: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.
2024-01-31 18:16:51 +05:30
2024-10-17 10:54:00 +01:00
# Windows GHA runner by default uses the pwsh shell which breaks codeSigningCert in the workflow
2025-02-11 09:30:35 +00:00
# We always sign using eSignerCKA to ensure it keeps working, but aside from release & nightlies we use demo credentials
# which do not yield trusted signatures.
2024-01-31 18:16:51 +05:30
defaults :
2024-01-31 19:15:14 +05:30
run :
shell : powershell
2022-11-11 15:15:21 +00:00
on :
2022-12-15 11:00:58 +00:00
workflow_call :
2023-02-22 13:51:19 +00:00
secrets :
ESIGNER_USER_NAME :
required : false
ESIGNER_USER_PASSWORD :
required : false
ESIGNER_USER_TOTP :
required : false
2022-12-15 11:00:58 +00:00
inputs :
arch :
type : string
required : true
2024-01-08 12:40:59 +00:00
description : "The architecture to build for, one of 'x64' | 'ia32' | 'arm64'"
2023-02-22 13:51:19 +00: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"
2024-11-22 10:18:33 +00:00
permissions : {} # No permissions required
2022-11-11 15:15:21 +00:00
jobs :
2022-12-15 11:00:58 +00:00
build :
2024-10-17 10:54:00 +01:00
runs-on : windows-2022
2023-02-22 13:51:19 +00:00
environment : ${{ inputs.sign && 'packages.element.io' || '' }}
2023-03-06 08:56:49 +00:00
env :
SIGNTOOL_PATH : "C:/Program Files (x86)/Windows Kits/10/bin/10.0.22000.0/x86/signtool.exe"
2022-12-15 11:00:58 +00:00
steps :
2024-02-13 11:07:00 +00:00
- uses : nbucic/variable-mapper@0673f6891a0619ba7c002ecfed0f9f4f39017b6f
2022-12-15 11:00:58 +00:00
id : config
with :
key : "${{ inputs.arch }}"
export_to : output
map : |
{
"x64": {
2024-01-08 12:40:59 +00:00
"target": "x86_64-pc-windows-msvc"
2022-12-15 11:00:58 +00:00
},
2023-03-22 09:41:51 +00:00
"arm64": {
"target": "aarch64-pc-windows-msvc" ,
"build-args": "--arm64" ,
2024-01-08 12:40:59 +00:00
"arch": "amd64_arm64"
2023-03-22 09:41:51 +00:00
},
2024-01-08 12:40:59 +00:00
"ia32": {
2022-12-15 11:00:58 +00:00
"target": "i686-pc-windows-msvc" ,
2023-02-27 10:47:40 +00:00
"build-args": "--ia32" ,
2025-03-03 10:08:22 +00:00
"arch": "x86" ,
2025-03-03 10:20:13 +00:00
"extra_config": "{\"user_notice\": {\"title\": \"Element will no longer be available for this platform soon\",\"description\": \"Support for 32-bit Windows installations will be removed in the next release.\"}}"
2022-12-15 11:00:58 +00:00
}
}
2022-11-14 11:09:07 +00:00
2024-01-02 17:24:45 +00:00
- uses : actions/checkout@v4
2022-11-11 15:15:21 +00:00
2024-01-08 12:40:59 +00:00
- uses : actions/download-artifact@v4
2022-12-15 11:00:58 +00:00
with :
name : webapp
2022-11-11 15:15:21 +00:00
2022-12-15 11:00:58 +00:00
- name : Cache .hak
id : cache
2024-01-23 20:03:17 +00:00
uses : actions/cache@v4
2022-12-15 11:00:58 +00:00
with :
2023-04-26 15:04:17 +01:00
key : ${{ runner.os }}-${{ inputs.arch }}-${{ hashFiles('hakHash', 'electronVersion') }}
2022-12-15 11:00:58 +00:00
path : |
./.hak
2022-11-11 15:15:21 +00:00
2022-12-15 11:00:58 +00: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 13:51:19 +00:00
if : steps.cache.outputs.cache-hit != 'true'
2022-12-15 11:00:58 +00: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 15:15:21 +00:00
2022-12-15 11:00:58 +00:00
- name : Choco install NetWide Assembler
2023-02-22 13:51:19 +00:00
if : steps.cache.outputs.cache-hit != 'true'
2022-12-15 11:00:58 +00: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 15:15:21 +00:00
2022-12-15 11:00:58 +00:00
- name : Install Rust
if : steps.cache.outputs.cache-hit != 'true'
2023-08-02 14:34:38 +01:00
run : |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
rustup target add ${{ steps.config.outputs.target }}
2022-11-11 15:15:21 +00:00
2024-01-02 17:37:20 +00:00
- uses : actions/setup-node@v4
2022-12-15 11:00:58 +00:00
with :
2025-02-28 10:23:49 +00:00
node-version-file : .node-version
2022-12-15 11:00:58 +00:00
cache : "yarn"
2022-11-11 15:15:21 +00:00
2022-12-15 11:00:58 +00:00
- name : Install Deps
2023-03-31 16:17:43 +01:00
run : "yarn install --frozen-lockfile"
2022-11-11 15:15:21 +00:00
2025-03-03 10:31:42 +00:00
- name : Insert config snippet
if : steps.config.outputs.extra_config != ''
shell : bash
run : |
mkdir config-edit
yarn asar extract webapp.asar config-edit
cd config-edit
mv config.json old-config.json
echo '${{ steps.config.outputs.extra_config }}' | jq -s '.[0] * .[1]' old-config.json - > config.json
rm old-config.json
cd ..
rm webapp.asar
yarn asar pack config-edit/ webpack.asar
2025-02-19 10:35:53 +00:00
- name : Set up sqlcipher macros
if : steps.cache.outputs.cache-hit != 'true' && contains(inputs.arch, 'arm')
shell : pwsh
run : |
echo "NCC=${{ github.workspace }}\scripts\cl.bat" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name : Set up build tools
if : steps.cache.outputs.cache-hit != 'true'
uses : ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with :
arch : ${{ steps.config.outputs.arch || inputs.arch }}
2022-12-15 11:00:58 +00:00
- name : Build Natives
if : steps.cache.outputs.cache-hit != 'true'
run : |
refreshenv
yarn build:native --target ${{ steps.config.outputs.target }}
2022-11-11 15:15:21 +00:00
2023-02-22 13:51:19 +00:00
- name : Install and configure eSigner CKA
run : |
Set-StrictMode -Version 'Latest'
2024-02-14 13:07:59 +00:00
# Download, extract, and rename
Invoke-WebRequest -OutFile eSigner_CKA.zip "$env:ESIGNER_URL"
Expand-Archive -Path eSigner_CKA.zip -DestinationPath .
Get-ChildItem -Path * -Include "*_build_*.exe" | Rename-Item -NewName eSigner_CKA.exe
2023-02-22 13:51:19 +00:00
# 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
2025-02-11 09:30:35 +00:00
# Configure - default credentials from https://www.ssl.com/guide/esigner-demo-credentials-and-certificates/
${{ env.INSTALL_DIR }}/eSignerCKATool.exe config `
-mode ${{ vars.ESIGNER_MODE || 'sandbox' }} `
-user "${{ secrets.ESIGNER_USER_NAME || 'esigner_demo' }}" `
-pass "${{ secrets.ESIGNER_USER_PASSWORD || 'esignerDemo#1' }}" `
-totp "${{ secrets.ESIGNER_USER_TOTP || 'RDXYgV9qju+6/7GnMf1vCbKexXVJmUVr+86Wq/8aIGg=' }}" `
-key "${{ env.MASTER_KEY_FILE }}" -r
2023-02-22 13:51:19 +00: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
2024-01-03 16:29:48 +00:00
2024-01-04 09:19:22 +00:00
echo "ED_SIGNTOOL_THUMBPRINT=$Thumbprint" >> $env:GITHUB_ENV
echo "ED_SIGNTOOL_SUBJECT_NAME=$SubjectName" >> $env:GITHUB_ENV
2023-02-22 13:51:19 +00:00
env :
2024-02-14 13:07:59 +00:00
ESIGNER_URL : https://github.com/SSLcom/eSignerCKA/releases/download/v1.0.6/SSL.COM-eSigner-CKA_1.0.6.zip
2023-02-22 13:51:19 +00:00
INSTALL_DIR : C:\Users\runneradmin\eSignerCKA
MASTER_KEY_FILE : C:\Users\runneradmin\eSignerCKA\master.key
2022-12-15 11:00:58 +00:00
- name : Build App
2025-02-19 10:02:49 +00:00
run : yarn build --publish never -w ${{ steps.config.outputs.build-args }}
env :
# Only set for Nightly builds
ED_NIGHTLY : ${{ inputs.version }}
2023-03-06 08:56:49 +00:00
2025-02-19 14:34:43 +00:00
- name : Trust eSigner sandbox cert
if : inputs.sign == ''
run : |
Set-StrictMode -Version 'Latest'
Import-Certificate -CertStoreLocation Cert:\LocalMachine\Root -FilePath .github/SSLcom-sandbox.crt
2023-03-06 08:56:49 +00:00
- name : Check app was signed successfully
run : |
2025-02-19 14:34:43 +00:00
Set-StrictMode -Version 'Latest'
Get-ChildItem `
-Recurse dist `
-Include *.exe, *.msi `
| ForEach-Object -Process {. $env:SIGNTOOL_PATH verify /pa $_.FullName; if(!$?) { throw }}
2023-02-22 13:51:19 +00:00
2022-12-15 11:00:58 +00:00
- name : Upload Artifacts
2024-01-08 12:40:59 +00:00
uses : actions/upload-artifact@v4
2022-12-15 11:00:58 +00:00
with :
2024-01-08 12:40:59 +00:00
name : win-${{ inputs.arch }}
path : |
dist
2022-12-15 11:00:58 +00:00
retention-days : 1
2025-02-19 14:34:43 +00:00
- name : Assert all required files are present
run : |
Test-Path './dist/win-*unpacked/Element*.exe'
Test-Path './dist/squirrel-windows*/Element Setup*.exe'
Test-Path './dist/squirrel-windows*/element-desktop-*-full.nupkg'
Test-Path './dist/squirrel-windows*/RELEASES'
Test-Path './dist/Element*.msi'