From be4a42b50a2899c982329ab5b46c4f0b8e119862 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Thu, 13 May 2021 21:06:59 -0400 Subject: [PATCH] Use GitHub Actions for building, refactor the builder configuration. --- .github/workflows/build.yml | 29 ++++++++++++++++ .travis.yml | 45 ------------------------ build.js | 68 ------------------------------------- electron-builder.yml | 46 +++++++++++++++++++++++++ package.json | 10 +++--- 5 files changed, 79 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml delete mode 100644 build.js create mode 100644 electron-builder.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..48078b0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build/release + +on: push + +jobs: + release: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + + steps: + - name: Check out Git repository + uses: actions/checkout@v1 + + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v1 + with: + node-version: 14 + + - name: Build/release Electron app + uses: samuelmeuli/action-electron-builder@v1 + with: + github_token: ${{ secrets.github_token }} + + # If the commit is tagged with a version (e.g. "v1.0.0"), + # release the app after building + release: ${{ startsWith(github.ref, 'refs/tags/v') }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1818e4e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -matrix: - include: - - os: osx - osx_image: xcode12.2 - language: node_js - node_js: "14" - env: - - ELECTRON_CACHE=$HOME/.cache/electron - - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder - - ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true - - CSC_IDENTITY_AUTO_DISCOVERY=false - - - os: linux - services: docker - language: generic - node_js: "14" - env: - - ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true - -cache: - directories: - - node_modules - - $HOME/.cache/electron - - $HOME/.cache/electron-builder - -script: - - | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - ENVS=`env | grep -iE '(DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|_TOKEN|_KEY|AWS_|STRIP|BUILD_)' | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' '` - docker run $ENVS --rm \ - -v ${PWD}:/project \ - -v ~/.cache/electron:/root/.cache/electron \ - -v ~/.cache/electron-builder:/root/.cache/electron-builder \ - electronuserland/builder:wine \ - /bin/bash -c "node -v && npm ci && npm run cilinux" - else - npm run cidarwin - fi - -before_cache: - - rm -rf $HOME/.cache/electron-builder/wine - -branches: - except: - - "/^v\\d+\\.\\d+\\.\\d+$/" \ No newline at end of file diff --git a/build.js b/build.js deleted file mode 100644 index e96e733..0000000 --- a/build.js +++ /dev/null @@ -1,68 +0,0 @@ -const builder = require('electron-builder') -const Platform = builder.Platform - -function getCurrentPlatform(){ - switch(process.platform){ - case 'win32': - return Platform.WINDOWS - case 'darwin': - return Platform.MAC - case 'linux': - return Platform.linux - default: - console.error('Cannot resolve current platform!') - return undefined - } -} - -builder.build({ - targets: (process.argv[2] != null && Platform[process.argv[2]] != null ? Platform[process.argv[2]] : getCurrentPlatform()).createTarget(), - config: { - appId: 'helioslauncher', - productName: 'Helios Launcher', - artifactName: '${productName}-setup-${version}.${ext}', - copyright: 'Copyright © 2018-2020 Daniel Scalzi', - directories: { - buildResources: 'build', - output: 'dist' - }, - win: { - target: [ - { - target: 'nsis', - arch: 'x64' - } - ] - }, - nsis: { - oneClick: false, - perMachine: false, - allowElevation: true, - allowToChangeInstallationDirectory: true - }, - mac: { - target: 'dmg', - category: 'public.app-category.games' - }, - linux: { - target: 'AppImage', - maintainer: 'Daniel Scalzi', - vendor: 'Daniel Scalzi', - synopsis: 'Modded Minecraft Launcher', - description: 'Custom launcher which allows users to join modded servers. All mods, configurations, and updates are handled automatically.', - category: 'Game' - }, - compression: 'maximum', - files: [ - '!{dist,.gitignore,.vscode,docs,dev-app-update.yml,.travis.yml,.nvmrc,.eslintrc.json,build.js}' - ], - extraResources: [ - 'libraries' - ], - asar: true - } -}).then(() => { - console.log('Build complete!') -}).catch(err => { - console.error('Error during build!', err) -}) \ No newline at end of file diff --git a/electron-builder.yml b/electron-builder.yml new file mode 100644 index 0000000..08175af --- /dev/null +++ b/electron-builder.yml @@ -0,0 +1,46 @@ +appId: 'helioslauncher' +productName: 'Helios Launcher' +artifactName: '${productName}-setup-${version}.${ext}' + +copyright: 'Copyright © 2018-2021 Daniel Scalzi' + +asar: true +compression: 'maximum' + +files: + - '!{dist,.gitignore,.vscode,docs,dev-app-update.yml,.travis.yml,.nvmrc,.eslintrc.json,build.js}' + +extraResources: + - 'libraries' + +# Windows Configuration +win: + target: + - target: 'nsis' + arch: 'x64' + +# Windows Installer Configuration +nsis: + oneClick: false + perMachine: false + allowElevation: true + allowToChangeInstallationDirectory: true + +# macOS Configuration +mac: + target: 'dmg' + category: 'public.app-category.games' + +# Linux Configuration +linux: + target: 'AppImage' + maintainer: 'Daniel Scalzi' + vendor: 'Daniel Scalzi' + synopsis: 'Modded Minecraft Launcher' + description: 'Custom launcher which allows users to join modded servers. All mods, configurations, and updates are handled automatically.' + category: 'Game' + + +directories: + buildResources: 'build' + output: 'dist' \ No newline at end of file diff --git a/package.json b/package.json index cbb19b6..6332432 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,10 @@ "main": "index.js", "scripts": { "start": "electron .", - "cilinux": "node build.js WINDOWS && node build.js LINUX", - "cidarwin": "node build.js MAC", - "dist": "cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true node build.js", - "dist:win": "npm run dist -- WINDOWS", - "dist:mac": "npm run dist -- MAC", - "dist:linux": "npm run dist -- LINUX", + "dist": "electron-builder build", + "dist:win": "npm run dist -- -w", + "dist:mac": "npm run dist -- -m", + "dist:linux": "npm run dist -- -l", "lint": "eslint --config .eslintrc.json ." }, "engines": {