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-01-31 14:22:30 +01:00
|
|
|
secrets:
|
|
|
|
APPLE_ID:
|
|
|
|
required: false
|
|
|
|
APPLE_ID_PASSWORD:
|
|
|
|
required: false
|
|
|
|
APPLE_TEAM_ID:
|
|
|
|
required: false
|
|
|
|
APPLE_CSC_KEY_PASSWORD:
|
|
|
|
required: false
|
|
|
|
APPLE_CSC_LINK:
|
|
|
|
required: false
|
|
|
|
inputs:
|
|
|
|
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"
|
|
|
|
base-url:
|
|
|
|
type: string
|
|
|
|
required: false
|
2024-01-08 13:40:59 +01:00
|
|
|
description: "The URL to which the output will be deployed."
|
2024-11-22 11:18:33 +01:00
|
|
|
permissions: {} # No permissions required
|
2022-11-11 16:15:21 +01:00
|
|
|
jobs:
|
2022-12-15 12:00:58 +01:00
|
|
|
build:
|
2024-01-31 14:05:08 +01:00
|
|
|
runs-on: macos-14 # M1
|
2023-01-31 14:22:30 +01:00
|
|
|
environment: ${{ inputs.sign && 'packages.element.io' || '' }}
|
2022-12-15 12:00:58 +01:00
|
|
|
steps:
|
2024-01-02 18:24:45 +01:00
|
|
|
- uses: actions/checkout@v4
|
2022-12-15 12:00:58 +01:00
|
|
|
|
2024-01-08 13:40:59 +01:00
|
|
|
- uses: actions/download-artifact@v4
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
|
|
|
name: webapp
|
|
|
|
|
|
|
|
- name: Cache .hak
|
|
|
|
id: cache
|
2024-01-23 21:03:17 +01:00
|
|
|
uses: actions/cache@v4
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
2023-04-26 16:04:17 +02:00
|
|
|
key: ${{ runner.os }}-${{ hashFiles('hakHash', 'electronVersion') }}
|
2022-12-15 12:00:58 +01:00
|
|
|
path: |
|
|
|
|
./.hak
|
|
|
|
|
|
|
|
- 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 aarch64-apple-darwin
|
2024-01-31 14:05:08 +01:00
|
|
|
rustup target add x86_64-apple-darwin
|
|
|
|
|
|
|
|
# M1 macos-14 comes without Python preinstalled
|
|
|
|
- uses: actions/setup-python@v5
|
|
|
|
with:
|
|
|
|
python-version: "3.12"
|
2022-12-15 12:00:58 +01:00
|
|
|
|
2024-01-02 18:37:20 +01:00
|
|
|
- uses: actions/setup-node@v4
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
2024-01-18 11:10:51 +01:00
|
|
|
node-version-file: package.json
|
2022-12-15 12:00:58 +01:00
|
|
|
cache: "yarn"
|
|
|
|
|
|
|
|
# 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-12-15 12:00:58 +01:00
|
|
|
|
|
|
|
- name: Build Natives
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2023-11-13 13:03:37 +01:00
|
|
|
run: |
|
|
|
|
# Python 3.12 drops distutils which keytar relies on
|
|
|
|
pip3 install setuptools
|
|
|
|
yarn build:native:universal
|
2022-12-15 12:00:58 +01:00
|
|
|
|
2023-02-22 14:51:19 +01:00
|
|
|
- name: "[Nightly] Resolve version"
|
2023-01-31 14:22:30 +01:00
|
|
|
if: inputs.version != ''
|
|
|
|
run: |
|
2024-01-03 17:29:48 +01:00
|
|
|
echo "ED_NIGHTLY=${{ inputs.version }}" >> $GITHUB_ENV
|
2023-01-31 14:22:30 +01:00
|
|
|
|
2023-01-31 16:49:41 +01:00
|
|
|
# We split these because electron-builder gets upset if we set CSC_LINK even to an empty string
|
2023-02-22 14:51:19 +01:00
|
|
|
- name: "[Signed] Build App"
|
2023-01-31 17:10:51 +01:00
|
|
|
if: inputs.sign != ''
|
2023-01-31 14:22:30 +01:00
|
|
|
run: |
|
2024-01-03 17:29:48 +01:00
|
|
|
yarn build:universal --publish never
|
2023-01-31 14:22:30 +01:00
|
|
|
env:
|
2024-10-25 13:17:31 +02:00
|
|
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
2023-03-22 10:40:39 +01:00
|
|
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
|
|
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
|
2023-01-31 14:22:30 +01:00
|
|
|
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CSC_KEY_PASSWORD }}
|
|
|
|
CSC_LINK: ${{ secrets.APPLE_CSC_LINK }}
|
2023-01-31 16:49:41 +01:00
|
|
|
|
2023-03-06 09:56:49 +01:00
|
|
|
- name: Check app was signed & notarised successfully
|
|
|
|
if: inputs.sign != ''
|
|
|
|
run: |
|
2024-01-09 16:56:04 +01:00
|
|
|
hdiutil attach dist/*.dmg -mountpoint /Volumes/Element
|
|
|
|
codesign -dv --verbose=4 /Volumes/Element/*.app
|
|
|
|
spctl -a -vvv -t install /Volumes/Element/*.app
|
|
|
|
hdiutil detach /Volumes/Element
|
2023-03-06 09:56:49 +01:00
|
|
|
|
2023-02-22 14:51:19 +01:00
|
|
|
- name: "[Unsigned] Build App"
|
2023-01-31 17:10:51 +01:00
|
|
|
if: inputs.sign == ''
|
2023-01-31 16:49:41 +01:00
|
|
|
run: |
|
2024-01-03 17:29:48 +01:00
|
|
|
yarn build:universal --publish never
|
2023-01-31 16:49:41 +01:00
|
|
|
env:
|
|
|
|
CSC_IDENTITY_AUTO_DISCOVERY: false
|
2023-01-31 14:22:30 +01:00
|
|
|
|
2024-01-08 13:40:59 +01:00
|
|
|
- name: Generate releases.json
|
|
|
|
if: inputs.base-url
|
2023-01-31 14:22:30 +01:00
|
|
|
run: |
|
|
|
|
PKG_JSON_VERSION=$(cat package.json | jq -r .version)
|
|
|
|
LATEST=$(find dist -type f -iname "*-mac.zip" | xargs -0 -n1 -- basename)
|
2023-02-27 10:45:54 +01:00
|
|
|
# Encode spaces in the URL as Squirrel.Mac complains about bad JSON otherwise
|
|
|
|
URL="${{ inputs.base-url }}/update/macos/${LATEST// /%20}"
|
2023-02-22 14:51:19 +01:00
|
|
|
|
2023-01-31 14:22:30 +01:00
|
|
|
jq -n --arg version "${VERSION:-$PKG_JSON_VERSION}" --arg url "$URL" '
|
|
|
|
{
|
|
|
|
currentRelease: $version,
|
|
|
|
releases: [{
|
|
|
|
version: $version,
|
|
|
|
updateTo: {
|
|
|
|
version: $version,
|
|
|
|
url: $url,
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
}
|
2024-01-08 13:40:59 +01:00
|
|
|
' > dist/releases.json
|
2023-01-31 14:22:30 +01:00
|
|
|
jq -n --arg url "$URL" '
|
|
|
|
{ url: $url }
|
2024-01-08 13:40:59 +01:00
|
|
|
' > dist/releases-legacy.json
|
2023-01-31 14:22:30 +01:00
|
|
|
env:
|
|
|
|
VERSION: ${{ inputs.version }}
|
|
|
|
|
2024-01-08 13:40:59 +01:00
|
|
|
# We exclude mac-universal as the unpacked app takes forever to upload and zip and dmg already contains it
|
2022-12-15 12:00:58 +01:00
|
|
|
- name: Upload Artifacts
|
2024-01-08 13:40:59 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2022-12-15 12:00:58 +01:00
|
|
|
with:
|
2024-01-08 13:40:59 +01:00
|
|
|
name: macos
|
2023-04-24 13:24:36 +02:00
|
|
|
path: |
|
|
|
|
dist
|
|
|
|
!dist/mac-universal/**
|
2022-12-15 12:00:58 +01:00
|
|
|
retention-days: 1
|