From d7b45e8a306f5185d2f9e15166c1e22fcbd718a7 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Wed, 6 Sep 2023 15:19:52 -0700 Subject: [PATCH] ci: first draft proof-of-concept GH Actions workflow --- .circleci/{config.yml => config-disabled.yml} | 0 .gitattributes | 1 + .github/workflows/ci.yml | 79 +++++++++++++++++++ .nvmrc | 1 + 4 files changed, 81 insertions(+) rename .circleci/{config.yml => config-disabled.yml} (100%) create mode 100644 .github/workflows/ci.yml create mode 100644 .nvmrc diff --git a/.circleci/config.yml b/.circleci/config-disabled.yml similarity index 100% rename from .circleci/config.yml rename to .circleci/config-disabled.yml diff --git a/.gitattributes b/.gitattributes index 4e6bb680..9d6e8857 100644 --- a/.gitattributes +++ b/.gitattributes @@ -27,6 +27,7 @@ .gitattributes text eol=lf .gitignore text eol=lf .npmignore text eol=lf +.nvmrc text eol=lf LICENSE text eol=lf Makefile text eol=lf TRADEMARK text eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..0c961208 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +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/* diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..b6a7d89c --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16