samuelmeuli / action-electron-builder

:electron: GitHub Action for building and releasing Electron apps
MIT License
658 stars 201 forks source link

Specifying TypeScript configuration file for Electron Builder - Fails on Windows #100

Closed nktnet1 closed 9 months ago

nktnet1 commented 9 months ago

The build for my application passes on macos-latest, ubuntu-latest and windows-latest when no --config econfig.ts is passed in the .github/workflows/build.yml file.

When I add the following:

          args: |
            --config econfig.ts

macos-latest and ubuntu-latest passes as expected, but the build for Windows fail with the following error message:

Run samuelmeuli/action-electron-builder@v1

Will run Yarn commands in directory "."

Installing dependencies using Yarn…
yarn install v1.22.21
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 50.41s.

Running the build script…
yarn run v1.22.21
$ tsc
Done in 5.32s.

Building the Electron app…
yarn run v1.22.21
$ D:\a\myapp\myapp\node_modules\.bin\electron-builder --windows --config econfig.ts
  • electron-builder  version=24.9.1 os=10.0.20348
  • artifacts will be published if draft release exists  reason=CI detected
compiling: [ 'D:\\a\\myapp\\myapp\\econfig.ts' ]
Could not write file 'C:/Users/runneradmin/.cache/config-file-ts/:-a-myapp-myapp-econfig.ts/a/myapp/myapp/econfig.js': EINVAL: invalid argument, mkdir 'C:/Users/runneradmin/.cache/config-file-ts/:-a-myapp-myapp-econfig.ts'.
  ⨯ ENOENT: no such file or directory, open 'C:\Users\runneradmin\.cache\config-file-ts\:-a-myapp-myapp-econfig.ts\_sources'  failedTask=build stackTrace=Error: ENOENT: no such file or directory, open 'C:\Users\runneradmin\.cache\config-file-ts\:-a-myapp-myapp-econfig.ts\_sources'
    at Object.open (node:internal/fs/sync:78:18)
    at Object.openSync (node:fs:565:17)
    at Object.writeFileSync (node:fs:2288:35)
    at saveExtendedSources (D:\a\myapp\myapp\node_modules\config-file-ts\src\compileUtil.ts:98:6)
    at compileIfNecessary (D:\a\myapp\myapp\node_modules\config-file-ts\src\compileUtil.ts:74:7)
    at compileConfigIfNecessary (D:\a\myapp\myapp\node_modules\config-file-ts\src\compileUtil.ts:173:19)
    at Object.loadTsConfig (D:\a\myapp\myapp\node_modules\config-file-ts\src\loadTsConfig.ts:18:20)
    at readConfig (D:\a\myapp\myapp\node_modules\read-config-file\src\main.ts:30:14)
    at getConfig (D:\a\myapp\myapp\node_modules\app-builder-lib\src\util\config.ts:44:34)
    at Packager.build (D:\a\myapp\myapp\node_modules\app-builder-lib\src\packager.ts:314:27)
    at executeFinally (D:\a\myapp\myapp\node_modules\builder-util\src\promise.ts:12:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
D:\a\_actions\samuelmeuli\action-electron-builder\v1\index.js:144
                throw err;
                ^

Error: Command failed: yarn run electron-builder --windows  --config econfig.ts

    at checkExecSyncError (node:child_process:861:11)
    at execSync (node:child_process:932:15)
    at run (D:\a\_actions\samuelmeuli\action-electron-builder\v1\index.js:21:27)
    at runAction (D:\a\_actions\samuelmeuli\action-electron-builder\v1\index.js:132:4)
    at Object.<anonymous> (D:\a\_actions\samuelmeuli\action-electron-builder\v1\index.js:150:1)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 5824,
  stdout: null,
  stderr: null
}

All Configuration Files (click to view)
build.yml ```yml # https://github.com/samuelmeuli/action-electron-builder name: Build/release on: push: branches: - main paths-ignore: - '**/README.md' pull_request: branches: - "*" paths-ignore: - '**/README.md' 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: 20 - name: Build/release Electron app uses: samuelmeuli/action-electron-builder@v1 with: args: | --config econfig.ts # GitHub token, automatically provided to the action # (No need to define this secret in the repo settings) 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') }} ``` econfig.ts: ```typescript import path from 'path'; import { Configuration } from 'electron-builder'; const config: Configuration = { icon: path.join('build', 'icon.png'), appId: 'com.nktnet.myapp', productName: 'myapp', asar: true, directories: { output: 'dist', }, files: [ 'out' ], extraResources: [ 'public' ], extraMetadata: { main: path.join('out', 'main.js'), }, win: { target: 'nsis', }, mac: { target: 'dmg', }, linux: { target: 'AppImage', category: 'Office', }, extends: null, }; export default config; ``` package.json ```json { "main": "./out/main.js", "scripts": { "start": "yarn build && electron .", "dev": "ts-node-dev -T src/server", "lint": "eslint --fix './**/*.{js,ts,cjs,mjs}'", "build": "tsc", "build:win": "yarn build && electron-builder --config econfig.ts --win", "build:mac": "yarn build && electron-builder --config econfig.ts --mac", "build:linux": "yarn build && electron-builder --config econfig.ts --linux" }, "dependencies": { "@electron-toolkit/utils": "^2.0.1", "electron-context-menu": "^3.6.1", "express": "^4.18.2" }, "devDependencies": { "@types/express": "^4.17.21", "@types/node": "^20.10.0", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", "electron": "^27.1.2", "electron-builder": "^24.9.1", "eslint": "^8.54.0", "ts-node-dev": "^2.0.0", "typescript": "^5.3.2" } ```
nktnet1 commented 9 months ago

Found related issue on electron-builder: