Skip to content

Add cross-platform GitHub Actions build & package workflow#1

Merged
Lexian-droid merged 3 commits intomasterfrom
copilot/add-github-actions-workflow
Mar 11, 2026
Merged

Add cross-platform GitHub Actions build & package workflow#1
Lexian-droid merged 3 commits intomasterfrom
copilot/add-github-actions-workflow

Conversation

Copy link

Copilot AI commented Mar 10, 2026

  • Add package:win, package:mac, package:linux scripts to package.json; update package to delegate to package:win
  • Create .github/workflows/build.yml with matrix build for ubuntu-latest, windows-latest, macos-latest (Node 20.x, no-audit npm install, platform-specific packaging, artifact upload, contents: read permissions)
  • Update README.md with artifact download instructions and local build documentation
  • Fix Windows artifact upload failure: remove single quotes from app name in electron-packager scripts (on Windows/PowerShell, single quotes are literal characters, causing the output folder to be named 'WeAnimate'-win32-x64 instead of WeAnimate-win32-x64)
Original prompt

Add a GitHub Actions workflow to GoExport/WeAnimate that builds and packages the Electron app on all three platforms (Windows, macOS, Linux) using the existing npm scripts.

Context

  • Repository: GoExport/WeAnimate (default branch: master)
  • Existing scripts in package.json:
    • npm run build: runs vite build && node scripts/build.mjs
    • npm run package: runs npx electron-packager dist 'WeAnimate' --icon=dist/favicon.ico --overwrite
  • The build step produces a dist/ folder containing the bundled Electron main (dist/main.js), static resources, and a minimal dist/package.json plus production dependencies installed into dist.

Requirements

  1. Create a workflow file at .github/workflows/build.yml (or similar) that:

    • Runs on push and pull_request.
    • Uses a matrix for ubuntu-latest, windows-latest, macos-latest.
    • Sets up Node.js (use an LTS compatible with >=16; prefer 20.x unless repo constraints require otherwise).
    • Caches npm dependencies.
    • Runs npm ci (or npm install if package-lock.json is absent) and then npm run build.
    • Runs packaging via npm run package.
    • Uploads the resulting packaged app folder(s) as workflow artifacts with clear names including OS and arch.
  2. Handle platform icon differences:

    • Current package script uses --icon=dist/favicon.ico.
    • Update packaging logic or workflow to use an .icns icon on macOS if required by electron-packager; ensure packaging succeeds on macOS.
    • Do not break existing local npm run package behavior; if changes are needed, prefer adding new scripts (e.g., package:win, package:mac, package:linux) and have the workflow call them.
  3. Ensure artifacts include platform outputs:

    • Windows: folder containing .exe
    • macOS: .app bundle folder
    • Linux: folder containing executable
  4. Add minimal documentation in README or comments in the workflow describing how to download artifacts.

Acceptance criteria

  • Workflow completes successfully on ubuntu-latest, windows-latest, macos-latest.
  • Artifacts are uploaded for each OS.
  • No secrets required.

Notes

  • Keep the workflow deterministic (pin action versions).
  • If there is no package-lock.json in the repo, use npm install and consider adding --no-audit --no-fund for CI speed.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: How do I build this project to electron executable? I want to do it for both Windows and Linux.

Assistant: This repo is already set up to produce a packaged Electron app via electron-packager, and it looks like the “Electron main process” entry is built into dist/main.js by scripts/build.mjs (it bundles src/main/index.ts into dist/main.js, then writes a minimal dist/package.json whose "main" is "main.js" and installs only runtime deps into dist/).

I can’t currently fetch src/main/index.ts / vite.config.mjs due to a GitHub read-tool limitation in this session, but you don’t need them to build a runnable executable—the npm scripts already define the pipeline.

Prereqs

  • Node.js >= 16 (repo enforces this in package.json engines)
  • npm (or compatible)
  • On Linux, you may need common Electron runtime deps (GTK, libnss3, etc.) depending on distro.

Build & package (same flow on Windows and Linux)

From the repo root:

  1. Install deps (runs a postinstall fixer):
npm install
  1. Build the app (Vite renderer + bundle Electron main into dist/):
npm run build
  1. Package into a platform-specific Electron “executable bundle”:
npm run package

What you should get:

  • A folder like WeAnimate-<platform>-<arch>/ created by electron-packager (by default it lands in the project root unless configured otherwise).
  • Inside is the runnable app:
    • Windows: WeAnimate.exe
    • Linux: WeAnimate (binary)

Building for Windows and Linux

Option A (recommended): build on each OS

Electron packaging is simplest when you run the commands on the target OS:

  • On Windows (PowerShell/CMD):

    npm install
    npm run build
    npm run package
  • On Linux:

    npm install
    npm run build
    npm run package

Option B: cross-build from one OS (often painful)

electron-packager can target other platforms, but cross-building frequently breaks due to native tooling/icon formats. Your current package script is:

"package": "npx electron-packager dist 'WeAnimate' --icon=dist/favicon.ico --overwrite"

To cross-target you’d typically add flags like --platform=win32 --arch=x64 or --platform=linux --arch=x64, but:

  • Windows from Linux/macOS may require extra setup (wine, rcedit, etc.).
  • Linux from Windows is also not always smooth.

If you tell me what machine you’re building from (Windows or Linux) and what CPU arch you need (x64 vs arm64), I can s...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…age scripts

Co-authored-by: Lexian-droid <83799577+Lexian-droid@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GitHub Actions workflow for building Electron app Add cross-platform GitHub Actions build & package workflow Mar 11, 2026
@Lexian-droid
Copy link
Member

@copilot It appears that the two windows related workflows have failed:

Error: No files were found with the provided path: WeAnimate-/. No artifacts will be uploaded.
Error: No files were found with the provided path: WeAnimate-
/. No artifacts will be uploaded.

Both workflows reported the same reason

…-packager scripts

Co-authored-by: Lexian-droid <83799577+Lexian-droid@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 11, 2026

@copilot It appears that the two windows related workflows have failed:

Error: No files were found with the provided path: WeAnimate-*/. No artifacts will be uploaded.
...

Root cause found from the logs:

Wrote new app to D:\a\WeAnimate\WeAnimate\'WeAnimate'-win32-x64

On Windows (PowerShell), single quotes are not string delimiters — they become literal characters in the argument. So electron-packager was creating a folder named 'WeAnimate'-win32-x64 (with actual single-quote characters), which didn't match the WeAnimate-*/ glob in the upload step.

Fixed in 68c66ae by removing the unnecessary single quotes from the app name in all three package:* scripts. Since WeAnimate contains no spaces, no quoting is needed.

@Lexian-droid Lexian-droid marked this pull request as ready for review March 11, 2026 01:06
@Lexian-droid Lexian-droid merged commit 738d9dd into master Mar 11, 2026
6 checks passed
@Lexian-droid Lexian-droid deleted the copilot/add-github-actions-workflow branch March 11, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants