2020-01-13 22:11:56 -05:00
|
|
|
version: 2.1
|
|
|
|
workflows:
|
2020-03-31 19:52:36 -04:00
|
|
|
macos:
|
|
|
|
jobs:
|
|
|
|
- build_for_macos:
|
2020-06-24 18:15:25 -04:00
|
|
|
context: scratch-desktop-and-link
|
2020-01-13 22:11:56 -05:00
|
|
|
windows:
|
|
|
|
jobs:
|
|
|
|
- build_for_windows:
|
2020-06-24 18:15:25 -04:00
|
|
|
context: scratch-desktop-and-link
|
2020-01-13 22:11:56 -05:00
|
|
|
orbs:
|
2023-04-03 13:04:02 -04:00
|
|
|
node: circleci/node@5.1.0
|
2023-04-04 05:34:38 -04:00
|
|
|
windows: circleci/windows@5.0.0
|
2020-06-25 18:30:21 -04:00
|
|
|
aliases:
|
2020-07-10 17:45:27 -04:00
|
|
|
# condition to indicate whether or not we should sign this build
|
2020-06-25 18:30:21 -04:00
|
|
|
- &should_sign
|
|
|
|
or:
|
2023-04-03 22:29:20 -04:00
|
|
|
- equal: [ develop, disable-<< pipeline.git.branch >> ]
|
|
|
|
- equal: [ main, disable-<< pipeline.git.branch >> ]
|
|
|
|
- equal: [ master, disable-<< pipeline.git.branch >> ]
|
2020-07-10 17:45:27 -04:00
|
|
|
# clear large environment variables from the "scratch-desktop-and-link" context
|
|
|
|
# this helps when a program (like NPM) encounters errors with a large environment
|
|
|
|
- &clear_context
|
|
|
|
CSC_MACOS: ""
|
|
|
|
MAC_PROVISION_PROFILE: ""
|
|
|
|
SDM_CERT: ""
|
|
|
|
SDM_CERT_CA_BUNDLE: ""
|
|
|
|
SDM_CERT_KEY: ""
|
|
|
|
WIN_CSC_LINK: ""
|
2020-03-31 19:52:36 -04:00
|
|
|
jobs:
|
|
|
|
build_for_macos:
|
|
|
|
macos:
|
2023-04-03 12:31:58 -04:00
|
|
|
# CircleCI's Xcode 11.7.0 image is the last of their images to be based on macOS 10.15
|
|
|
|
# CircleCI no longer supports macOS 10.14, and Xcode 12 on macOS 10.15 has been removed as well
|
|
|
|
xcode: 11.7.0
|
|
|
|
resource_class: macos.x86.medium.gen2 # "medium" has been deprecated
|
2020-03-31 19:52:36 -04:00
|
|
|
steps:
|
2023-04-03 13:04:02 -04:00
|
|
|
- node/install:
|
|
|
|
node-version: "16.*"
|
|
|
|
- run: node --version && npm --version
|
2020-03-31 19:52:36 -04:00
|
|
|
- checkout
|
2023-04-03 15:53:15 -04:00
|
|
|
- node/install-packages:
|
|
|
|
include-branch-in-cache-key: false
|
2023-04-03 22:19:05 -04:00
|
|
|
override-ci-command: npm ci --loglevel info --prefer-offline
|
2020-06-25 18:58:45 -04:00
|
|
|
- run:
|
|
|
|
name: Test
|
|
|
|
command: npm run test
|
2020-06-25 18:30:21 -04:00
|
|
|
- when:
|
|
|
|
condition:
|
|
|
|
*should_sign
|
|
|
|
steps:
|
2022-01-26 13:07:14 -05:00
|
|
|
- add_ssh_keys
|
2020-06-25 18:30:21 -04:00
|
|
|
- run:
|
2020-06-25 19:01:48 -04:00
|
|
|
name: Import CI context
|
2020-06-25 18:30:21 -04:00
|
|
|
command: |
|
|
|
|
set -e
|
2022-01-27 12:33:48 -05:00
|
|
|
fastlane circleci
|
2020-06-24 18:44:46 -04:00
|
|
|
- restore_cache:
|
2020-08-03 16:18:40 -04:00
|
|
|
# Caching Homebrew's files (see the save_cache step below) means that Homebrew doesn't have to update as
|
|
|
|
# much. The Homebrew update can take several minutes without this, but with the cache it tends to take less
|
|
|
|
# than a minute most of the time. The cache will expire periodically and be replaced by a more up-to-date
|
|
|
|
# cache, which should effectively cap the amount of updating that Homebrew needs to do on top of the cache.
|
2020-06-24 18:44:46 -04:00
|
|
|
name: Restore Homebrew cache
|
2022-02-22 13:20:38 -05:00
|
|
|
key: homebrew-cache-v2
|
2020-06-24 18:44:46 -04:00
|
|
|
- run:
|
|
|
|
name: Work around electron-userland/electron-builder#4964
|
2023-04-03 12:31:58 -04:00
|
|
|
environment:
|
|
|
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
2020-06-24 18:44:46 -04:00
|
|
|
command: |
|
|
|
|
brew install go go-bindata
|
|
|
|
git -C ~ clone https://github.com/develar/app-builder.git
|
|
|
|
git -C ~/app-builder checkout b85740334fec875f5dd8dcd22eb1f729599109db
|
|
|
|
make --directory=~/app-builder build
|
|
|
|
ln -sfv ~/app-builder/dist/app-builder_darwin_amd64/app-builder ./node_modules/app-builder-bin/mac/
|
|
|
|
- save_cache:
|
|
|
|
name: Save Homebrew cache
|
|
|
|
paths:
|
|
|
|
- ~/Library/Caches/Homebrew
|
2022-02-22 13:20:38 -05:00
|
|
|
- /Library/Caches/Homebrew
|
|
|
|
key: homebrew-cache-v2
|
2020-06-25 19:13:39 -04:00
|
|
|
- build
|
2020-03-31 19:52:36 -04:00
|
|
|
- run:
|
2020-06-29 15:23:22 -04:00
|
|
|
name: Move DMG to artifacts directory
|
2020-03-31 19:52:36 -04:00
|
|
|
command: |
|
|
|
|
mkdir -p Artifacts/
|
2020-06-29 15:23:22 -04:00
|
|
|
mv -v dist/Scratch*.dmg Artifacts/
|
|
|
|
- when:
|
|
|
|
condition:
|
|
|
|
*should_sign
|
|
|
|
steps:
|
2020-07-13 16:14:15 -04:00
|
|
|
- run:
|
|
|
|
name: Zip MAS-Dev to artifacts directory
|
|
|
|
# If you use `zip` for this it will throw away some metadata (resource forks?) and
|
|
|
|
# the app will crash on startup with "EXC_CRASH (Code Signature Invalid)".
|
|
|
|
# To preserve that metadata, use `ditto` instead.
|
|
|
|
# See also: https://stackoverflow.com/a/22370486
|
|
|
|
command: |
|
|
|
|
NPM_APP_VERSION="`node -pe "require('./package.json').version"`"
|
|
|
|
cd dist/mas-dev
|
|
|
|
ditto -v -c -k --sequesterRsrc --keepParent --zlibCompressionLevel 9 \
|
2020-07-27 14:54:03 -04:00
|
|
|
Scratch*.app ../../Artifacts/mas-dev-${NPM_APP_VERSION}.zip
|
2020-06-29 15:23:22 -04:00
|
|
|
- run:
|
|
|
|
name: Move PKG to artifacts directory
|
|
|
|
command: |
|
|
|
|
mv -v dist/mas/Scratch*.pkg Artifacts/
|
2020-03-31 19:52:36 -04:00
|
|
|
- store_artifacts:
|
|
|
|
path: Artifacts/
|
|
|
|
build_for_windows:
|
2023-04-03 13:04:02 -04:00
|
|
|
executor:
|
|
|
|
name: windows/default
|
|
|
|
shell: bash.exe # defaulting to bash at the executor level makes the Node orb kinda work
|
2020-03-31 19:52:36 -04:00
|
|
|
steps:
|
2020-04-03 18:27:25 -04:00
|
|
|
- run:
|
|
|
|
# work around https://github.com/appveyor/ci/issues/2420 which seems to affect CircleCI too
|
|
|
|
# see also https://circleci.com/docs/2.0/env-vars/#using-parameters-and-bash-environment
|
|
|
|
name: Work around git-sh-setup issue
|
2020-07-10 17:32:47 -04:00
|
|
|
shell: bash
|
2020-04-03 18:27:25 -04:00
|
|
|
command: |
|
|
|
|
echo 'Adding libexec/git-core to PATH...'
|
|
|
|
echo 'For more details see https://github.com/appveyor/ci/issues/2420'
|
|
|
|
echo 'export PATH="$PATH:/c/Program Files/Git/mingw64/libexec/git-core"' >> $BASH_ENV
|
2023-04-03 13:04:02 -04:00
|
|
|
- run: # node/install doesn't work right on Windows
|
|
|
|
name: Install Node
|
|
|
|
# as of today, the Windows image comes with nvm 1.1.7
|
|
|
|
# nvm version 1.1.9 fixes an issue leading to "npm ERR! Unexpected token '.'"
|
|
|
|
# nvm version 1.1.10 will support "nvm install 16"
|
|
|
|
# but for now it needs the exact version
|
2021-06-03 01:43:07 -04:00
|
|
|
command: |
|
2023-04-03 13:04:02 -04:00
|
|
|
choco upgrade --yes nvm.portable
|
|
|
|
nvm --version
|
|
|
|
nvm install 16.20.0
|
|
|
|
nvm use 16.20.0
|
|
|
|
- run: node --version && npm --version
|
2020-03-31 19:52:36 -04:00
|
|
|
- checkout
|
2023-04-03 13:04:02 -04:00
|
|
|
- node/install-packages:
|
|
|
|
# the Node orb doesn't understand the default cache path on Windows
|
|
|
|
# make sure to use a path that works with Windows Node.js AND MSYS/MinGW bash
|
|
|
|
cache-path: "C:/tmp/npm-cache"
|
2023-04-03 15:53:15 -04:00
|
|
|
include-branch-in-cache-key: false
|
2023-04-03 22:19:05 -04:00
|
|
|
override-ci-command: npm ci --loglevel info --prefer-offline
|
2020-06-25 18:58:45 -04:00
|
|
|
- run:
|
|
|
|
name: Test
|
|
|
|
command: npm run test
|
2020-07-10 17:45:27 -04:00
|
|
|
environment: *clear_context
|
2020-06-25 18:30:21 -04:00
|
|
|
- when:
|
|
|
|
condition:
|
2020-06-26 12:26:48 -04:00
|
|
|
*should_sign
|
2020-06-25 18:30:21 -04:00
|
|
|
steps:
|
|
|
|
- run:
|
2020-06-26 12:26:48 -04:00
|
|
|
name: Import CI context
|
|
|
|
shell: bash
|
2020-06-25 18:30:21 -04:00
|
|
|
command: |
|
2020-06-26 12:26:48 -04:00
|
|
|
set -e
|
|
|
|
function decodeToFile () {
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Missing or invalid filename"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo "Missing environment variable contents for file: $1"
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
echo "$2" | base64 --decode > "$1"
|
2020-06-25 18:30:21 -04:00
|
|
|
}
|
2020-06-26 12:26:48 -04:00
|
|
|
decodeToFile ~/codesign.pfx "${WIN_CSC_LINK}"
|
|
|
|
- run:
|
|
|
|
# In theory this should be unnecessary: the electron-builder documentation says that WIN_CSC_LINK can
|
|
|
|
# be a base64-encoded certificate, which is what's in the CI context. In practice that leads to an
|
|
|
|
# signtool.exe finding the certificate but not the key, for reasons I haven't been able to understand.
|
|
|
|
# Also, because of the non-standard user configuration on CircleCI's Windows VM, attempting to import
|
|
|
|
# a certificate into the user's certificate store ("Cert:/LocalUser/My") will fail. Instead, this code
|
|
|
|
# imports the PFX into the machine certificate store. That usually requires Administrator permissions,
|
|
|
|
# but on CircleCI's setup it works just fine. See also: https://github.com/ShabadOS/desktop/issues/265
|
|
|
|
# and https://github.com/ShabadOS/desktop/pull/266
|
|
|
|
name: Add CSC to machine store
|
|
|
|
shell: powershell
|
|
|
|
command: |
|
|
|
|
$securePassword = (ConvertTo-SecureString -String $env:WIN_CSC_KEY_PASSWORD -AsPlainText -Force)
|
|
|
|
Import-PfxCertificate -FilePath ~/codesign.pfx -Password $securePassword -CertStoreLocation "Cert:/LocalMachine/My"
|
2020-06-25 19:13:39 -04:00
|
|
|
- build
|
2020-01-13 22:11:56 -05:00
|
|
|
- run:
|
2020-03-31 19:52:36 -04:00
|
|
|
name: Move Windows build products to artifacts directory
|
2020-07-10 17:32:47 -04:00
|
|
|
shell: bash
|
2020-01-13 22:11:56 -05:00
|
|
|
command: |
|
|
|
|
mkdir -p Artifacts/
|
|
|
|
mv dist/{Scratch*.appx,Scratch*.exe} Artifacts/
|
|
|
|
- store_artifacts:
|
|
|
|
path: Artifacts/
|
2020-04-03 17:06:28 -04:00
|
|
|
commands:
|
2020-06-25 19:13:39 -04:00
|
|
|
build:
|
|
|
|
steps:
|
|
|
|
- when:
|
|
|
|
condition:
|
|
|
|
*should_sign
|
|
|
|
steps:
|
2020-06-26 12:26:48 -04:00
|
|
|
- run:
|
|
|
|
command: npm run dist
|
2020-07-10 18:53:59 -04:00
|
|
|
no_output_timeout: 30m # macOS notarization can take longer than the default 10 minutes
|
2020-06-26 12:26:48 -04:00
|
|
|
environment:
|
2020-07-31 20:47:36 -04:00
|
|
|
# blank big variables to avoid crash on Windows
|
2020-07-10 17:45:27 -04:00
|
|
|
<<: *clear_context
|
2020-07-31 20:47:36 -04:00
|
|
|
# let Windows know where to get the PFX (ignored on non-Windows builds)
|
2020-07-10 17:45:27 -04:00
|
|
|
WIN_CSC_LINK: ~/codesign.pfx
|
2020-07-31 20:47:36 -04:00
|
|
|
# blank CIRCLE_BUILD_NUM to work around electron-userland/electron-builder#5016
|
|
|
|
CIRCLE_BUILD_NUM: ""
|
2020-06-25 19:13:39 -04:00
|
|
|
- unless:
|
|
|
|
condition:
|
|
|
|
*should_sign
|
|
|
|
steps:
|
2020-07-10 17:45:27 -04:00
|
|
|
- run:
|
|
|
|
command: npm run distDev
|
2023-07-24 10:18:24 -04:00
|
|
|
environment:
|
|
|
|
<<: *clear_context
|
|
|
|
# increased Node memory needed for macOS build
|
|
|
|
NODE_OPTIONS: --max-old-space-size=4096
|