From 8c0f88375473f5e9c86b4d932976ce694c203149 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 11:54:57 +0000 Subject: [PATCH 01/33] Add way to provide apple ID and app password to notarise script --- scripts/electron_afterSign.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/electron_afterSign.js b/scripts/electron_afterSign.js index 691996fec8..ebd89f5e39 100644 --- a/scripts/electron_afterSign.js +++ b/scripts/electron_afterSign.js @@ -8,12 +8,21 @@ exports.default = async function(context) { if (electronPlatformName === 'darwin') { const appName = context.packager.appInfo.productFilename; - const keychainProfile = process.env.NOTARIZE_KEYCHAIN_PROFILE; - if (keychainProfile === undefined) { + const notarizeToolCredentials = {}; + if (process.env.NOTARIZE_KEYCHAIN_PROFILE) { + notarizeToolCredentials.keychainProfile = process.env.NOTARIZE_KEYCHAIN_PROFILE; + notarizeToolCredentials.keychain = process.env.NOTARIZE_KEYCHAIN; + } if (process.env.NOTARIZE_APPLE_ID && process.env.NOTARIZE_APPLE_ID_PASSWORD && process.env.NOTARIZE_TEAM_ID) { + notarizeToolCredentials.appleId = process.env.NOTARIZE_APPLE_ID; + notarizeToolCredentials.appleIdPassword = process.env.NOTARIZE_APPLE_ID_PASSWORD; + notarizeToolCredentials.teamId = process.env.NOTARIZE_TEAM_ID; + } else { if (!warned) { console.log("*****************************************"); - console.log("* NOTARIZE_KEYCHAIN_PROFILE is not set. *"); console.log("* This build will NOT be notarised. *"); + console.log("* Provide NOTARIZE_KEYCHAIN_PROFILE or *"); + console.log("* NOTARIZE_APPLE_ID, NOTARIZE_TEAM_ID *"); + console.log("* and NOTARIZE_APPLE_ID_PASSWORD *"); console.log("*****************************************"); warned = true; } @@ -25,8 +34,7 @@ exports.default = async function(context) { tool: "notarytool", appBundleId: appId, appPath: `${appOutDir}/${appName}.app`, - keychainProfile, - keychain: process.env.NOTARIZE_KEYCHAIN, + ...notarizeToolCredentials, }); } }; From ea41482d321cf9c66b2cd2d73b17f8b43f3be4c0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 11:55:31 +0000 Subject: [PATCH 02/33] Add utility to generate electron-builder.json for release & nightly builds --- scripts/generate-builder-config.ts | 131 +++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 scripts/generate-builder-config.ts diff --git a/scripts/generate-builder-config.ts b/scripts/generate-builder-config.ts new file mode 100644 index 0000000000..4325eede87 --- /dev/null +++ b/scripts/generate-builder-config.ts @@ -0,0 +1,131 @@ +#!/usr/bin/env -S npx ts-node + +/** + * Script to generate electron-builder.json config files for builds which don't match package.json, e.g. nightlies + * This script has different outputs depending on your os platform. + * + * On Windows: + * Prefixes the nightly version with `0.0.1-nightly.` as it breaks if it is not semver + * + * On Linux: + * Replaces spaces in the product name with dashes as spaces in paths can cause issues + * Passes --deb-custom-control to build.deb.fpm if specified + */ + +import parseArgs from "minimist"; +import fsProm from "fs/promises"; +import * as os from "os"; + +const ELECTRON_BUILDER_CFG_FILE = "electron-builder.json"; + +const NIGHTLY_APP_ID = "im.riot.nightly"; +const NIGHTLY_APP_NAME = "element-desktop-nightly"; + +const argv = parseArgs<{ + nightly?: string; + "deb-custom-control"?: string; +}>(process.argv.slice(2), { + string: ["nightly", "deb-custom-control"], +}); + +interface File { + from: string; + to: string; +} + +interface PackageBuild { + appId: string; + asarUnpack: string; + files: Array; + extraResources: Array; + linux: { + target: string; + category: string; + maintainer: string; + desktop: { + StartupWMClass: string; + }; + }; + mac: { + category: string; + darkModeSupport: boolean; + }; + win: { + target: { + target: string; + }; + sign: string; + }; + deb?: { + fpm?: string[]; + }; + directories: { + output: string; + }; + afterPack: string; + afterSign: string; + protocols: Array<{ + name: string; + schemes: string[]; + }>; + extraMetadata?: { + productName?: string; + name?: string; + version?: string; + }; +} + +interface Package { + build: PackageBuild; + productName: string; +} + +async function main(): Promise { + // Electron builder doesn't overlay with the config in package.json, so load it here + const pkg: Package = JSON.parse(await fsProm.readFile("package.json", "utf8")); + + const cfg: PackageBuild = { + ...pkg.build, + extraMetadata: { + productName: pkg.productName, + }, + }; + + if (argv.nightly) { + cfg.appId = NIGHTLY_APP_ID; + cfg.extraMetadata!.productName += " Nightly"; + cfg.extraMetadata!.name = NIGHTLY_APP_NAME; + + let version = argv.nightly; + if (os.platform() === "win32") { + // The windows packager relies on parsing this as semver, so we have to make it look like one. + // This will give our update packages really stupid names, but we probably can't change that either + // because squirrel windows parses them for the version too. We don't really care: nobody sees them. + // We just give the installer a static name, so you'll just see this in the 'about' dialog. + // Turns out if you use 0.0.0 here it makes Squirrel windows crash, so we use 0.0.1. + version = "0.0.1-nightly." + version; + } + cfg.extraMetadata!.version = version; + } + + if (os.platform() === "linux") { + // Electron crashes on debian if there's a space in the path. + // /~https://github.com/vector-im/element-web/issues/13171 + cfg.extraMetadata!.productName = cfg.extraMetadata!.productName!.replace(/ /g, "-"); + + if (argv["deb-custom-control"]) { + cfg.deb = { + fpm: [`--deb-custom-control=${argv["deb-custom-control"]}`], + }; + } + } + + await fsProm.writeFile(ELECTRON_BUILDER_CFG_FILE, JSON.stringify(cfg, null, 4)); +} + +main().then((ret) => { + process.exit(ret!); +}).catch(e => { + console.error(e); + process.exit(1); +}); From d07379df88d33a69fb897fea35144919a1509dcb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 11:55:47 +0000 Subject: [PATCH 03/33] Run Build & Test on staging too --- .github/workflows/{build.yaml => build_and_test.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build.yaml => build_and_test.yaml} (98%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build_and_test.yaml similarity index 98% rename from .github/workflows/build.yaml rename to .github/workflows/build_and_test.yaml index 28972efd87..f5c362e6bf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build_and_test.yaml @@ -2,7 +2,7 @@ name: Build and Test on: pull_request: { } push: - branches: [ develop, master ] + branches: [ develop, staging, master ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true From 6d4415fc22beada2649af0e72ab03d11decfb608 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 12:18:08 +0000 Subject: [PATCH 04/33] First attempt at build & deploy for macOS with signing and notarisation --- .github/workflows/build_and_deploy.yaml | 91 +++++++++++++++++++++++++ .github/workflows/build_macos.yaml | 75 +++++++++++++++++++- .github/workflows/packages_index.yaml | 8 ++- 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_and_deploy.yaml diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml new file mode 100644 index 0000000000..ea01906fbb --- /dev/null +++ b/.github/workflows/build_and_deploy.yaml @@ -0,0 +1,91 @@ +name: Build and Deploy +on: + # XXX: REMOVE BEFORE PR LANDS + push: + branches: [ t3chguy/notarize1 ] + # Nightly build + schedule: + - cron: '0 11 * * *' + # Manual nightly & release + workflow_dispatch: + inputs: + mode: + description: What type of build to trigger. Release builds should be ran from the `master` branch. + required: true + default: nightly + type: choice + options: + - nightly + - release + deploy: + description: Whether to deploy artifacts + required: true + type: boolean + default: true +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + fetch: + uses: ./.github/workflows/build_prepare.yaml + with: + config: "element.io/${{ inputs.mode }}' + version: ${{ inputs.mode == 'nightly' && 'develop' || '' }} + +# windows: +# needs: fetch +# name: Windows +# uses: ./.github/workflows/build_windows.yaml +# secrets: inherit +# strategy: +# matrix: +# arch: [ x64, x86 ] +# with: +# arch: ${{ matrix.arch }} + +# linux: +# needs: fetch +# name: Linux +# uses: ./.github/workflows/build_linux.yaml +# secrets: inherit +# strategy: +# matrix: +# sqlcipher: [ system, static ] +# with: +# sqlcipher: ${{ matrix.sqlcipher }} + + macos: + needs: fetch + name: macOS + uses: ./.github/workflows/build_macos.yaml + secrets: inherit + with: + sign: true + deploy-mode: true + base-url: https://packages.element.io/${{ inputs.mode == 'nightly' && 'nightly' || 'desktop' }} + # TODO this needs to be dynamic + version: 2022121309 + + deploy: + needs: +# - windows +# - linux + - macos + name: Deploy + if: inputs.deploy + environment: develop + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: packages.element.io + + - name: Deploy artifacts + run: aws s3 cp --recursive packages.element.io/ s3://$R2_BUCKET/ --endpoint-url $R2_URL --region auto + env: + # XXX: UPDATE THIS BEFORE LANDING THE PR + R2_BUCKET: 'packages-element-io-test' + R2_URL: ${{ secrets.CF_R2_S3_API }} + AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} + diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index a3000e7ce7..3452d13b70 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -1,8 +1,37 @@ on: workflow_call: + 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 'develop' environment" + deploy-mode: + type: string + required: false + description: "Whether to arrange artifacts in the arrangement needed for deployment, skipping unrelated ones" + base-url: + type: string + required: false + description: "The URL to which the output will be deployed, required if deploy-mode is enabled." jobs: build: runs-on: macos-latest + environment: ${{ inputs.sign && "develop" }} steps: - uses: actions/checkout@v3 @@ -34,12 +63,56 @@ jobs: - name: Build Natives run: "yarn build:native:universal" + - name: Generate Nightly build config + if: inputs.version + run: scripts/generate-builder-config.ts --nightly "${{ inputs.version }}" + - name: Build App run: "yarn build:universal --publish never" + env: + NOTARIZE_APPLE_ID: ${{ secrets.APPLE_ID }} + NOTARIZE_APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + NOTARIZE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + CSC_KEY_PASSWORD: ${{ secrets.APPLE_CSC_KEY_PASSWORD }} + CSC_LINK: ${{ secrets.APPLE_CSC_LINK }} + + - name: Prepare artifacts for deployment + if: inputs.deploy-mode + run: | + mv dist _dist + mkdir -p dist/install/macos dist/update/macos + mv _dist/*.dmg _dist/*-mac.zip dist/ + + PKG_JSON_VERSION=$(cat package.json | jq -r .version) + VERSION="${{ inputs.version }}" + LATEST=$(find dist -type f -iname "*-mac.zip" | xargs -0 -n1 -- basename) + URL="${{ inputs.base-url }}/update/macos/$LATEST" + + jq -n --arg version "${VERSION:-$PKG_JSON_VERSION}" --arg url "$URL" ' + { + currentRelease: $version, + releases: [{ + version: $version, + updateTo: { + version: $version, + url: $url, + }, + }], + } + ' > dist/update/macos/releases.json + jq -n --arg version "${VERSION:-$PKG_JSON_VERSION}" --arg url "$URL" ' + { url: $url } + ' > dist/update/macos/releases-legacy.json + + - name: Prepare release latest symlink + if: inputs.deploy-mode && inputs.version == '' + run: | + LATEST=$(find dist -type f -iname "*.dmg" | xargs -0 -n1 -- basename) + ln -s "dist/install/macos/$LATEST" dist/install/macos/Element.dmg - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: macos + name: ${{ inputs.deploy-mode && 'packages.element.io' || 'macos' }} path: dist retention-days: 1 diff --git a/.github/workflows/packages_index.yaml b/.github/workflows/packages_index.yaml index b9a563e865..de33621bda 100644 --- a/.github/workflows/packages_index.yaml +++ b/.github/workflows/packages_index.yaml @@ -5,14 +5,20 @@ on: branches: [ develop ] paths: - 'packages.element.io/**' - # Trigger a daily rebuild for nightlies + # Trigger a daily rebuild for (mac-mini built) Nightly builds schedule: - cron: '0 11 * * *' + # Trigger after Nightly builds are deployed + workflow_run: + workflows: [ "Build and Deploy" ] + types: + - completed # Manual trigger for rebuilding for releases workflow_dispatch: { } jobs: deploy: name: "Deploy" + if: github.event != 'workflow_run' || github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest environment: develop env: From f289b94133d9cbe329e917aabd5571503ffb3173 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 12:18:56 +0000 Subject: [PATCH 05/33] Fix quote mismatch --- .github/workflows/build_and_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index ea01906fbb..9dadb18e18 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -29,7 +29,7 @@ jobs: fetch: uses: ./.github/workflows/build_prepare.yaml with: - config: "element.io/${{ inputs.mode }}' + config: 'element.io/${{ inputs.mode }}' version: ${{ inputs.mode == 'nightly' && 'develop' || '' }} # windows: From 605783ccfecfac89d0489dfbacf2cf2cfd35a428 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 12:33:27 +0000 Subject: [PATCH 06/33] use correct quotes --- .github/workflows/build_macos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 3452d13b70..72ffb16002 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -31,7 +31,7 @@ on: jobs: build: runs-on: macos-latest - environment: ${{ inputs.sign && "develop" }} + environment: ${{ inputs.sign && 'develop' || '' }} steps: - uses: actions/checkout@v3 From 7ff97cfa4f179250b9b170c2002ae63d65b32a29 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 12:34:36 +0000 Subject: [PATCH 07/33] add runs-on --- .github/workflows/build_and_deploy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 9dadb18e18..3aca2de907 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -71,6 +71,7 @@ jobs: # - windows # - linux - macos + runs-on: ubuntu-latest name: Deploy if: inputs.deploy environment: develop From c83f6cbf1e21135b4ab0416c1eb3d85dd9030cf7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 12:37:52 +0000 Subject: [PATCH 08/33] Fix inputs.mode usage --- .github/workflows/build_and_deploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 3aca2de907..91ba1ac87e 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -29,8 +29,8 @@ jobs: fetch: uses: ./.github/workflows/build_prepare.yaml with: - config: 'element.io/${{ inputs.mode }}' - version: ${{ inputs.mode == 'nightly' && 'develop' || '' }} + config: 'element.io/${{ inputs.mode || 'nightly' }}' + version: ${{ inputs.mode == 'release' && '' || 'develop' }} # windows: # needs: fetch @@ -62,7 +62,7 @@ jobs: with: sign: true deploy-mode: true - base-url: https://packages.element.io/${{ inputs.mode == 'nightly' && 'nightly' || 'desktop' }} + base-url: https://packages.element.io/${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} # TODO this needs to be dynamic version: 2022121309 From 45b6c33254ba4d696276fa88d23028faa4e314e5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 12:43:39 +0000 Subject: [PATCH 09/33] remove quotes --- .github/workflows/build_and_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 91ba1ac87e..eefba600a0 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -29,7 +29,7 @@ jobs: fetch: uses: ./.github/workflows/build_prepare.yaml with: - config: 'element.io/${{ inputs.mode || 'nightly' }}' + config: element.io/${{ inputs.mode || 'nightly' }} version: ${{ inputs.mode == 'release' && '' || 'develop' }} # windows: From d4bbd0c0c8b4a435dcf662d93e28c5cc48fa644e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 13:13:55 +0000 Subject: [PATCH 10/33] chmod +x --- scripts/generate-builder-config.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/generate-builder-config.ts diff --git a/scripts/generate-builder-config.ts b/scripts/generate-builder-config.ts old mode 100644 new mode 100755 From 84b8cd6f7e247064bed1558c2990141ace4d3a80 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 14:22:52 +0000 Subject: [PATCH 11/33] Fix artifact paths --- .github/workflows/build_macos.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index ef2a604567..78f92e1ee4 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -87,7 +87,8 @@ jobs: run: | mv dist _dist mkdir -p dist/install/macos dist/update/macos - mv _dist/*.dmg _dist/*-mac.zip dist/ + mv _dist/*-mac.zip dist/update/macos/ + mv _dist/*.dmg dist/install/macos/ PKG_JSON_VERSION=$(cat package.json | jq -r .version) VERSION="${{ inputs.version }}" From 68070c843f3501f92444b94a92eb44173ceced50 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Dec 2022 14:23:12 +0000 Subject: [PATCH 12/33] Fix deploy condition --- .github/workflows/build_and_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index eefba600a0..0d7a5b683f 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -73,7 +73,7 @@ jobs: - macos runs-on: ubuntu-latest name: Deploy - if: inputs.deploy + if: inputs.deploy != false environment: develop steps: - name: Download artifacts From f6ff5ed9c3868a09ebf141df07eb6294694f41aa Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 10:49:45 +0000 Subject: [PATCH 13/33] Fix deploy condition --- .github/workflows/build_and_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 0d7a5b683f..d0420c0c69 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -73,7 +73,7 @@ jobs: - macos runs-on: ubuntu-latest name: Deploy - if: inputs.deploy != false + if: github.event != 'workflow_dispatch' || inputs.deploy environment: develop steps: - name: Download artifacts From fcc0988b70a9c62499705633e528d25478e800ba Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 11:27:05 +0000 Subject: [PATCH 14/33] Fix artifact path --- .github/workflows/build_and_deploy.yaml | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index d0420c0c69..387f3e8a03 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -32,28 +32,6 @@ jobs: config: element.io/${{ inputs.mode || 'nightly' }} version: ${{ inputs.mode == 'release' && '' || 'develop' }} -# windows: -# needs: fetch -# name: Windows -# uses: ./.github/workflows/build_windows.yaml -# secrets: inherit -# strategy: -# matrix: -# arch: [ x64, x86 ] -# with: -# arch: ${{ matrix.arch }} - -# linux: -# needs: fetch -# name: Linux -# uses: ./.github/workflows/build_linux.yaml -# secrets: inherit -# strategy: -# matrix: -# sqlcipher: [ system, static ] -# with: -# sqlcipher: ${{ matrix.sqlcipher }} - macos: needs: fetch name: macOS @@ -68,8 +46,6 @@ jobs: deploy: needs: -# - windows -# - linux - macos runs-on: ubuntu-latest name: Deploy @@ -80,6 +56,7 @@ jobs: uses: actions/download-artifact@v3 with: name: packages.element.io + path: packages.element.io - name: Deploy artifacts run: aws s3 cp --recursive packages.element.io/ s3://$R2_BUCKET/ --endpoint-url $R2_URL --region auto From d407cba12abad93cf362adf35318ff412d362a2c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 12:10:50 +0000 Subject: [PATCH 15/33] Iterate --- .github/workflows/build_and_deploy.yaml | 9 +++++---- .github/workflows/build_macos.yaml | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 387f3e8a03..47fde1822e 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -25,6 +25,8 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + DEPLOYMENT_DIR: ${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} jobs: fetch: uses: ./.github/workflows/build_prepare.yaml @@ -40,7 +42,7 @@ jobs: with: sign: true deploy-mode: true - base-url: https://packages.element.io/${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} + base-url: https://packages.element.io/${{ env.DEPLOYMENT_DIR }} # TODO this needs to be dynamic version: 2022121309 @@ -50,7 +52,7 @@ jobs: runs-on: ubuntu-latest name: Deploy if: github.event != 'workflow_dispatch' || inputs.deploy - environment: develop + environment: packages.element.io steps: - name: Download artifacts uses: actions/download-artifact@v3 @@ -59,11 +61,10 @@ jobs: path: packages.element.io - name: Deploy artifacts - run: aws s3 cp --recursive packages.element.io/ s3://$R2_BUCKET/ --endpoint-url $R2_URL --region auto + run: aws s3 cp --recursive packages.element.io/ s3://$R2_BUCKET/$DEPLOYMENT_DIR --endpoint-url $R2_URL --region auto env: # XXX: UPDATE THIS BEFORE LANDING THE PR R2_BUCKET: 'packages-element-io-test' R2_URL: ${{ secrets.CF_R2_S3_API }} AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} - diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 78f92e1ee4..15e102981a 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -111,7 +111,12 @@ jobs: { url: $url } ' > dist/update/macos/releases-legacy.json - - name: Prepare release latest symlink + - name: [Nightly] Strip version from installer file + if: inputs.deploy-mode && inputs.version + run: | + mv dist/install/macos/*.dmg "dist/install/macos/Element Nightly.dmg" + + - name: [Release] Prepare release latest symlink if: inputs.deploy-mode && inputs.version == '' run: | LATEST=$(find dist -type f -iname "*.dmg" | xargs -0 -n1 -- basename) From 813dfdd43f7645b151d622e31b120bfcaa339d51 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 12:11:38 +0000 Subject: [PATCH 16/33] Fix workflow --- .github/workflows/build_macos.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 15e102981a..dd74faa14a 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -111,12 +111,12 @@ jobs: { url: $url } ' > dist/update/macos/releases-legacy.json - - name: [Nightly] Strip version from installer file + - name: '[Nightly] Strip version from installer file' if: inputs.deploy-mode && inputs.version run: | mv dist/install/macos/*.dmg "dist/install/macos/Element Nightly.dmg" - - name: [Release] Prepare release latest symlink + - name: '[Release] Prepare release latest symlink' if: inputs.deploy-mode && inputs.version == '' run: | LATEST=$(find dist -type f -iname "*.dmg" | xargs -0 -n1 -- basename) From 542bac0794da51fbdcff5e59a89f12040d853448 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 12:15:48 +0000 Subject: [PATCH 17/33] Fix env --- .github/workflows/build_and_deploy.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 47fde1822e..a13ed8716a 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -25,8 +25,6 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - DEPLOYMENT_DIR: ${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} jobs: fetch: uses: ./.github/workflows/build_prepare.yaml @@ -42,7 +40,7 @@ jobs: with: sign: true deploy-mode: true - base-url: https://packages.element.io/${{ env.DEPLOYMENT_DIR }} + base-url: https://packages.element.io/${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} # TODO this needs to be dynamic version: 2022121309 @@ -68,3 +66,4 @@ jobs: R2_URL: ${{ secrets.CF_R2_S3_API }} AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} + DEPLOYMENT_DIR: ${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} From 4f57fb865924c80fea0eb63c6714402a08387b98 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 14:27:28 +0000 Subject: [PATCH 18/33] Iterate --- .github/workflows/build_and_deploy.yaml | 23 +++++++++----- .github/workflows/build_macos.yaml | 3 +- .github/workflows/build_prepare.yaml | 25 +++++++++++++++ scripts/generate-nightly-version.ts | 41 +++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 8 deletions(-) create mode 100755 scripts/generate-nightly-version.ts diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index a13ed8716a..20d5a62cf0 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -17,6 +17,11 @@ on: options: - nightly - release + macos: + description: Whether to build macOS + required: true + type: boolean + default: true deploy: description: Whether to deploy artifacts required: true @@ -25,15 +30,23 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + # XXX: UPDATE THIS BEFORE LANDING THE PR + R2_BUCKET: 'packages-element-io-test' + R2_URL: ${{ secrets.CF_R2_S3_API }} jobs: - fetch: + prepare: uses: ./.github/workflows/build_prepare.yaml with: config: element.io/${{ inputs.mode || 'nightly' }} version: ${{ inputs.mode == 'release' && '' || 'develop' }} + calculate-nightly-versions: ${{ inputs.mode != 'release' }} + secrets: + CF_R2_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} + CF_R2_TOKEN: ${{ secrets.CF_R2_TOKEN }} macos: - needs: fetch + needs: prepare name: macOS uses: ./.github/workflows/build_macos.yaml secrets: inherit @@ -41,8 +54,7 @@ jobs: sign: true deploy-mode: true base-url: https://packages.element.io/${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} - # TODO this needs to be dynamic - version: 2022121309 + version: ${{ needs.prepare.outputs.macos-version }} deploy: needs: @@ -61,9 +73,6 @@ jobs: - name: Deploy artifacts run: aws s3 cp --recursive packages.element.io/ s3://$R2_BUCKET/$DEPLOYMENT_DIR --endpoint-url $R2_URL --region auto env: - # XXX: UPDATE THIS BEFORE LANDING THE PR - R2_BUCKET: 'packages-element-io-test' - R2_URL: ${{ secrets.CF_R2_S3_API }} AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} DEPLOYMENT_DIR: ${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index dd74faa14a..f1ec320c59 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -34,7 +34,7 @@ on: jobs: build: runs-on: macos-latest - environment: ${{ inputs.sign && 'develop' || '' }} + environment: ${{ inputs.sign && 'packages.element.io' || '' }} steps: - uses: actions/checkout@v3 @@ -111,6 +111,7 @@ jobs: { url: $url } ' > dist/update/macos/releases-legacy.json + # 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 run: | diff --git a/.github/workflows/build_prepare.yaml b/.github/workflows/build_prepare.yaml index 2d790e8a9a..bc8ef123fd 100644 --- a/.github/workflows/build_prepare.yaml +++ b/.github/workflows/build_prepare.yaml @@ -9,10 +9,28 @@ on: type: string required: false description: "The version tag to fetch, or 'develop', will pick automatically if not passed" + calculate-nightly-versions: + type: string + required: false + description: "Whether to calculate the version strings new Nightly builds should use" + secrets: + # Required if `calculate-nightly-versions` is set + CF_R2_ACCESS_KEY_ID: + required: false + # Required if `calculate-nightly-versions` is set + CF_R2_TOKEN: + required: false + outputs: + macos-version: + description: "The version string the next macOS Nightly should use, only output for calculate-nightly-versions" + value: ${{ jobs.prepare.outputs.macos-version }} jobs: prepare: name: Prepare + environment: ${{ inputs.calculate-nightly-versions && 'packages.element.io' || '' }} runs-on: ubuntu-latest + outputs: + macos-version: ${{ steps.macos.outputs.version }} steps: - uses: actions/checkout@v3 @@ -41,3 +59,10 @@ jobs: package.json electronVersion hakDependencies.json + + - name: Calculate macOS Nightly version + id: macos + if: inputs.calculate-nightly-versions + run: | + LATEST=$(aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json - --endpoint-url $R2_URL --region auto | jq -r .currentRelease) + echo "version=$(scripts/generate-nightly-version.ts --latest $LATEST)" >> $GITHUB_OUTPUT diff --git a/scripts/generate-nightly-version.ts b/scripts/generate-nightly-version.ts new file mode 100755 index 0000000000..6cc7686140 --- /dev/null +++ b/scripts/generate-nightly-version.ts @@ -0,0 +1,41 @@ +#!/usr/bin/env -S npx ts-node + +/** + * Script to generate incremental Nightly build versions, based on the latest Nightly build version of that kind. + * The version format is YYYYMMDDNN where NN is in case we need to do multiple versions in a day. + * + * NB. on windows, squirrel will try to parse the version number parts, including this string, into 32-bit integers, + * which is fine as long as we only add two digits to the end... + */ + +import parseArgs from "minimist"; + +const argv = parseArgs<{ + latest?: string; +}>(process.argv.slice(2), { + string: ["latest"], +}); + +function parseVersion(version: string): [Date, number] { + const year = parseInt(version.slice(0, 4), 10); + const month = parseInt(version.slice(4, 2), 10); + const day = parseInt(version.slice(6, 2), 10); + const num = parseInt(version.slice(8, 2), 10); + return [new Date(year, month - 1, day), num]; +} + +const [latestDate, latestNum] = argv.latest ? parseVersion(argv.latest) : []; + +const now = new Date(); +const month = (now.getMonth() + 1).toString().padStart(2, '0'); +const date = now.getDate().toString().padStart(2, '0'); +let buildNum = 1; +if (latestDate && new Date(latestDate).getDate().toString().padStart(2, '0') === date) { + buildNum = latestNum! + 1; +} + +if (buildNum > 99) { + throw new Error("Maximum number of Nightlies exceeded on this day."); +} + +console.log(now.getFullYear() + month + date + buildNum.toString().padStart(2, '0') + buildNum); From d36159025d3a3e8b3d8a02d871c70d4ae5a6044f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 14:31:13 +0000 Subject: [PATCH 19/33] Fix missing env --- .github/workflows/build_prepare.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build_prepare.yaml b/.github/workflows/build_prepare.yaml index bc8ef123fd..ddfed229e6 100644 --- a/.github/workflows/build_prepare.yaml +++ b/.github/workflows/build_prepare.yaml @@ -1,3 +1,4 @@ +# This action helps perform common actions before the build_* actions are started in parallel. on: workflow_call: inputs: @@ -66,3 +67,6 @@ jobs: run: | LATEST=$(aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json - --endpoint-url $R2_URL --region auto | jq -r .currentRelease) echo "version=$(scripts/generate-nightly-version.ts --latest $LATEST)" >> $GITHUB_OUTPUT + env: + AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} From 05993abd6a639b4fb3604605ee60fd7ec1e32458 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 14:33:05 +0000 Subject: [PATCH 20/33] Fix version calculation --- .github/workflows/build_prepare.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_prepare.yaml b/.github/workflows/build_prepare.yaml index ddfed229e6..801f45a926 100644 --- a/.github/workflows/build_prepare.yaml +++ b/.github/workflows/build_prepare.yaml @@ -65,7 +65,8 @@ jobs: id: macos if: inputs.calculate-nightly-versions run: | - LATEST=$(aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json - --endpoint-url $R2_URL --region auto | jq -r .currentRelease) + aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json releases.json --endpoint-url $R2_URL --region auto + LATEST=$(cat releases.json | jq -r .currentRelease) echo "version=$(scripts/generate-nightly-version.ts --latest $LATEST)" >> $GITHUB_OUTPUT env: AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} From 6a2c8e0b75f3771840fe2e21dc22ef2241ab417c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 14:36:09 +0000 Subject: [PATCH 21/33] Iterate --- .github/workflows/build_and_deploy.yaml | 3 ++- .github/workflows/build_prepare.yaml | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 20d5a62cf0..86a6dd94d0 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -33,7 +33,6 @@ concurrency: env: # XXX: UPDATE THIS BEFORE LANDING THE PR R2_BUCKET: 'packages-element-io-test' - R2_URL: ${{ secrets.CF_R2_S3_API }} jobs: prepare: uses: ./.github/workflows/build_prepare.yaml @@ -44,6 +43,7 @@ jobs: secrets: CF_R2_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} CF_R2_TOKEN: ${{ secrets.CF_R2_TOKEN }} + CF_R2_S3_API: ${{ secrets.CF_R2_S3_API }} macos: needs: prepare @@ -75,4 +75,5 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} + R2_URL: ${{ secrets.CF_R2_S3_API }} DEPLOYMENT_DIR: ${{ inputs.mode == 'release' && 'desktop' || 'nightly' }} diff --git a/.github/workflows/build_prepare.yaml b/.github/workflows/build_prepare.yaml index 801f45a926..81808556e1 100644 --- a/.github/workflows/build_prepare.yaml +++ b/.github/workflows/build_prepare.yaml @@ -21,6 +21,9 @@ on: # Required if `calculate-nightly-versions` is set CF_R2_TOKEN: required: false + # Required if `calculate-nightly-versions` is set + CF_R2_S3_API: + required: false outputs: macos-version: description: "The version string the next macOS Nightly should use, only output for calculate-nightly-versions" @@ -65,9 +68,9 @@ jobs: id: macos if: inputs.calculate-nightly-versions run: | - aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json releases.json --endpoint-url $R2_URL --region auto - LATEST=$(cat releases.json | jq -r .currentRelease) + LATEST=$(aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json - --endpoint-url $R2_URL --region auto | jq -r .currentRelease) echo "version=$(scripts/generate-nightly-version.ts --latest $LATEST)" >> $GITHUB_OUTPUT env: AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }} + R2_URL: ${{ secrets.CF_R2_S3_API }} From 3f2acaba98cec6b02786d3433b45161f738f9f73 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Dec 2022 15:08:30 +0000 Subject: [PATCH 22/33] Fix config not taking effect --- .github/workflows/build_and_deploy.yaml | 4 ++-- .github/workflows/build_macos.yaml | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 86a6dd94d0..bb343013ee 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -5,7 +5,7 @@ on: branches: [ t3chguy/notarize1 ] # Nightly build schedule: - - cron: '0 11 * * *' + - cron: '0 9 * * *' # Manual nightly & release workflow_dispatch: inputs: @@ -31,7 +31,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: - # XXX: UPDATE THIS BEFORE LANDING THE PR + # XXX: UPDATE THIS BEFORE WHEN GOING LIVE R2_BUCKET: 'packages-element-io-test' jobs: prepare: diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index f1ec320c59..7ae5dc948f 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -69,12 +69,16 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: "yarn build:native:universal" - - name: Generate Nightly build config + - name: '[Nightly] Generate build config' if: inputs.version run: scripts/generate-builder-config.ts --nightly "${{ inputs.version }}" + - name: '[Release] Generate build config' + if: inputs.version == '' + run: scripts/generate-builder-config.ts + - name: Build App - run: "yarn build:universal --publish never" + run: "yarn build:universal --publish never --config electron-builder.json" env: NOTARIZE_APPLE_ID: ${{ secrets.APPLE_ID }} NOTARIZE_APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} @@ -91,7 +95,6 @@ jobs: mv _dist/*.dmg dist/install/macos/ PKG_JSON_VERSION=$(cat package.json | jq -r .version) - VERSION="${{ inputs.version }}" LATEST=$(find dist -type f -iname "*-mac.zip" | xargs -0 -n1 -- basename) URL="${{ inputs.base-url }}/update/macos/$LATEST" @@ -110,6 +113,8 @@ jobs: jq -n --arg version "${VERSION:-$PKG_JSON_VERSION}" --arg url "$URL" ' { url: $url } ' > dist/update/macos/releases-legacy.json + env: + VERSION: ${{ inputs.version }} # 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' From 1b70e493bf6033237a853c6c7e36c214169d4aab Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 16 Jan 2023 11:45:41 +0000 Subject: [PATCH 23/33] Update build_and_deploy.yaml --- .github/workflows/build_and_deploy.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index bb343013ee..7d2026b49d 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -1,8 +1,5 @@ name: Build and Deploy on: - # XXX: REMOVE BEFORE PR LANDS - push: - branches: [ t3chguy/notarize1 ] # Nightly build schedule: - cron: '0 9 * * *' From 36b403b696665531190a0922a32f24b83cbc6feb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 16 Jan 2023 11:53:19 +0000 Subject: [PATCH 24/33] Fix alignments --- .github/workflows/build_macos.yaml | 34 ++++++++++++++-------------- .github/workflows/build_prepare.yaml | 20 ++++++++-------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 2750a8464e..9652607188 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -14,23 +14,23 @@ on: 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 'develop' environment" - deploy-mode: - type: string - required: false - description: "Whether to arrange artifacts in the arrangement needed for deployment, skipping unrelated ones" - base-url: - type: string - required: false - description: "The URL to which the output will be deployed, required if deploy-mode is enabled." + 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 'develop' environment" + deploy-mode: + type: string + required: false + description: "Whether to arrange artifacts in the arrangement needed for deployment, skipping unrelated ones" + base-url: + type: string + required: false + description: "The URL to which the output will be deployed, required if deploy-mode is enabled." jobs: build: runs-on: macos-latest diff --git a/.github/workflows/build_prepare.yaml b/.github/workflows/build_prepare.yaml index 1d13a78100..e4a1197d94 100644 --- a/.github/workflows/build_prepare.yaml +++ b/.github/workflows/build_prepare.yaml @@ -14,16 +14,16 @@ on: type: string required: false description: "Whether to calculate the version strings new Nightly builds should use" - secrets: - # Required if `calculate-nightly-versions` is set - CF_R2_ACCESS_KEY_ID: - required: false - # Required if `calculate-nightly-versions` is set - CF_R2_TOKEN: - required: false - # Required if `calculate-nightly-versions` is set - CF_R2_S3_API: - required: false + secrets: + # Required if `calculate-nightly-versions` is set + CF_R2_ACCESS_KEY_ID: + required: false + # Required if `calculate-nightly-versions` is set + CF_R2_TOKEN: + required: false + # Required if `calculate-nightly-versions` is set + CF_R2_S3_API: + required: false outputs: macos-version: description: "The version string the next macOS Nightly should use, only output for calculate-nightly-versions" From 324bafb92db062b25b246c49b91d1271469d7b90 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 16 Jan 2023 11:53:47 +0000 Subject: [PATCH 25/33] delint --- scripts/generate-builder-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-builder-config.ts b/scripts/generate-builder-config.ts index 4325eede87..adaaddb751 100755 --- a/scripts/generate-builder-config.ts +++ b/scripts/generate-builder-config.ts @@ -125,7 +125,7 @@ async function main(): Promise { main().then((ret) => { process.exit(ret!); -}).catch(e => { +}).catch((e) => { console.error(e); process.exit(1); }); From 5ff69a03e42434c33e42458f7a70e5ef7f692fec Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 16 Jan 2023 11:54:20 +0000 Subject: [PATCH 26/33] Fix alignment --- .github/workflows/build_prepare.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_prepare.yaml b/.github/workflows/build_prepare.yaml index e4a1197d94..c974a91297 100644 --- a/.github/workflows/build_prepare.yaml +++ b/.github/workflows/build_prepare.yaml @@ -24,10 +24,10 @@ on: # Required if `calculate-nightly-versions` is set CF_R2_S3_API: required: false - outputs: - macos-version: - description: "The version string the next macOS Nightly should use, only output for calculate-nightly-versions" - value: ${{ jobs.prepare.outputs.macos-version }} + outputs: + macos-version: + description: "The version string the next macOS Nightly should use, only output for calculate-nightly-versions" + value: ${{ jobs.prepare.outputs.macos-version }} jobs: prepare: name: Prepare From e3b969511e40247910b60b0177c8006517219c54 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 16 Jan 2023 13:03:15 +0000 Subject: [PATCH 27/33] Update build_macos.yaml --- .github/workflows/build_macos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 9652607188..efd6a127e3 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -22,7 +22,7 @@ on: sign: type: string required: false - description: "Whether to sign & notarise the build, requires 'develop' environment" + description: "Whether to sign & notarise the build, requires 'packages.element.io' environment" deploy-mode: type: string required: false From 250502a2ec00223e192a1ae74991ab1bd596a87f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 17 Jan 2023 11:21:20 +0000 Subject: [PATCH 28/33] Update build_and_deploy.yaml --- .github/workflows/build_and_deploy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 7d2026b49d..16448e0e80 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -43,6 +43,7 @@ jobs: CF_R2_S3_API: ${{ secrets.CF_R2_S3_API }} macos: + if: inputs.macos needs: prepare name: macOS uses: ./.github/workflows/build_macos.yaml From 60988662c13ab9088fd3114cfb00b7ad38864e94 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Jan 2023 17:13:59 +0000 Subject: [PATCH 29/33] Update build_macos.yaml --- .github/workflows/build_macos.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index efd6a127e3..82550eb12d 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -69,16 +69,16 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: "yarn build:native:universal" - - name: '[Nightly] Generate build config' - if: inputs.version - run: scripts/generate-builder-config.ts --nightly "${{ inputs.version }}" - - - name: '[Release] Generate build config' - if: inputs.version == '' - run: scripts/generate-builder-config.ts + - name: '[Nightly] Resolve version' + id: nightly + if: inputs.version != '' + run: | + echo "config-args=--nightly '${{ inputs.version }}'" >> $GITHUB_OUTPUT - name: Build App - run: "yarn build:universal --publish never --config electron-builder.json" + run: | + scripts/generate-builder-config.ts ${{ steps.nightly.outputs.config-args }} + yarn build:universal --publish never --config electron-builder.json env: NOTARIZE_APPLE_ID: ${{ secrets.APPLE_ID }} NOTARIZE_APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} @@ -118,7 +118,7 @@ jobs: # 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 + if: inputs.deploy-mode && inputs.version != '' run: | mv dist/install/macos/*.dmg "dist/install/macos/Element Nightly.dmg" From 13861599aabb13e6335033979ce1ff2113498759 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Jan 2023 17:15:50 +0000 Subject: [PATCH 30/33] Update build_and_deploy.yaml --- .github/workflows/build_and_deploy.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 16448e0e80..c425048c2a 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -1,5 +1,8 @@ name: Build and Deploy on: + # XXX: REMOVE THIS BEFORE MERGING + push: + branches: ["t3chguy/notarize1"] # Nightly build schedule: - cron: '0 9 * * *' @@ -59,7 +62,7 @@ jobs: - macos runs-on: ubuntu-latest name: Deploy - if: github.event != 'workflow_dispatch' || inputs.deploy + if: always() && (github.event != 'workflow_dispatch' || inputs.deploy) environment: packages.element.io steps: - name: Download artifacts From b90d665e4fe2fc7450e9deac6632cd75bcaf79f4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Jan 2023 17:17:30 +0000 Subject: [PATCH 31/33] Update build_macos.yaml --- .github/workflows/build_macos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 82550eb12d..3830e90501 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -110,7 +110,7 @@ jobs: }], } ' > dist/update/macos/releases.json - jq -n --arg version "${VERSION:-$PKG_JSON_VERSION}" --arg url "$URL" ' + jq -n --arg url "$URL" ' { url: $url } ' > dist/update/macos/releases-legacy.json env: From f880b7b5a5ba42fce86a84bc575e1e53577db056 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Jan 2023 17:20:45 +0000 Subject: [PATCH 32/33] Update build_and_deploy.yaml --- .github/workflows/build_and_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index c425048c2a..43b2371579 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -46,7 +46,7 @@ jobs: CF_R2_S3_API: ${{ secrets.CF_R2_S3_API }} macos: - if: inputs.macos + if: github.event_name != 'workflow_dispatch' || inputs.macos needs: prepare name: macOS uses: ./.github/workflows/build_macos.yaml From 14d0761f01ba669cb623f126b6e9408ee5644c7c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 31 Jan 2023 10:44:29 +0000 Subject: [PATCH 33/33] Update build_and_deploy.yaml --- .github/workflows/build_and_deploy.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 43b2371579..fc551cd7bf 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -1,8 +1,5 @@ name: Build and Deploy on: - # XXX: REMOVE THIS BEFORE MERGING - push: - branches: ["t3chguy/notarize1"] # Nightly build schedule: - cron: '0 9 * * *'