ci: first draft proof-of-concept GH Actions workflow #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI build | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
permissions: | |
contents: read | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-latest] # [windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'npm' | |
node-version-file: '.nvmrc' | |
- run: node --version && npm --version | |
- run: npm ci | |
- run: npm run test | |
- if: runner.os == 'Windows' | |
run: echo "Import CI context" | |
- if: runner.os == 'Windows' | |
run: echo "Add CSC to machine store" | |
- if: runner.os == 'macOS' | |
run: fastlane circleci | |
- name: Work around electron-userland/electron-builder#4964 | |
if: runner.os == 'macOS' | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
run: | | |
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/ | |
- name: Build | |
env: | |
# let Windows know where to get the PFX (ignored on non-Windows builds) | |
WIN_CSC_LINK: ~/codesign.pfx | |
# blank CIRCLE_BUILD_NUM to work around electron-userland/electron-builder#5016 | |
CIRCLE_BUILD_NUM: "" | |
# increased Node memory needed for macOS build | |
NODE_OPTIONS: --max-old-space-size=4096 | |
run: | | |
npm run distDev | |
- name: Create Artifacts directory | |
shell: bash | |
run: mkdir -p Artifacts | |
- name: Move DMG to Artifacts | |
if: runner.os == 'macOS' | |
run: mv -v dist/Scratch*.dmg Artifacts/ | |
- name: Move PKG to Artifacts | |
if: runner.os == 'macOS' # TODO: only if signed | |
run: mv -v dist/Scratch*.pkg Artifacts/ | |
- name: Zip MAS-Dev build | |
if: runner.os == 'macOS' # TODO: only if signed | |
# 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 | |
run: | | |
NPM_APP_VERSION="`node -pe "require('./package.json').version"`" | |
cd dist/mas-dev | |
ditto -v -c -k --sequesterRsrc --keepParent --zlibCompressionLevel 9 \ | |
Scratch*.app ../../Artifacts/mas-dev-${NPM_APP_VERSION}.zip | |
- name: Move Windows build products to Artifacts | |
if: runner.os == 'Windows' | |
shell: bash | |
run: mv -v dist/{Scratch*.appx,Scratch*.exe} Artifacts/ | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: Artifacts/* |