Эх сурвалжийг харах

Use GitHub Actions for building, refactor the builder configuration.

Daniel Scalzi 4 жил өмнө
parent
commit
be4a42b50a
5 өөрчлөгдсөн 79 нэмэгдсэн , 119 устгасан
  1. 29 0
      .github/workflows/build.yml
  2. 0 45
      .travis.yml
  3. 0 68
      build.js
  4. 46 0
      electron-builder.yml
  5. 4 6
      package.json

+ 29 - 0
.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') }}

+ 0 - 45
.travis.yml

@@ -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+$/"

+ 0 - 68
build.js

@@ -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)
-})

+ 46 - 0
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'

+ 4 - 6
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": {