Skip to content

Commit

Permalink
Refactor build command in windows-build.yml: Update NSIS installation…
Browse files Browse the repository at this point in the history
… and add x64 architecture support
  • Loading branch information
minai621 committed Oct 18, 2024
1 parent 1b73907 commit f2650d1
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 79 deletions.
83 changes: 45 additions & 38 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: electron-windows-nsis-build
name: Build and Publish Electron App

on:
push:
Expand All @@ -7,59 +7,66 @@ on:

jobs:
build:
runs-on: windows-2019
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [18.x]
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: "18.x"

- name: Set up pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8

- name: Install global electron-builder
run: npm install -g [email protected]

- name: Check NSIS version
run: |
$nsisPath = "C:\Program Files (x86)\NSIS\makensis.exe"
if (Test-Path $nsisPath) {
Write-Output "NSIS version:"
& $nsisPath /VERSION
} else {
Write-Output "NSIS not found in expected location."
exit 1
}
shell: pwsh

- name: Clear npm cache
run: npm cache clean --force

- name: Install Dependencies
run: pnpm install --prefer-offline --no-frozen-lockfile
working-directory: ./native
- name: Install dependencies
run: pnpm install

- name: Build Electron App
- name: Build TypeScript
run: pnpm run build
working-directory: ./native

- name: Create NSIS Installer
run: pnpm run electron-builder -- --win --publish always
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Make Electron app
run: pnpm run make
working-directory: ./native

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
files: ./native/release/**/*.exe
name: ${{ matrix.os }}-build
path: native/out/make/**/*

publish:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18.x"

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8

- name: Install dependencies
run: pnpm install
working-directory: ./native

- name: Publish Electron app
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run publish
working-directory: ./native
87 changes: 46 additions & 41 deletions native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,63 @@
"license": "Apache-2.0",
"scripts": {
"build": "tsc src/main.ts --outDir dist",
"start": "pnpm run build && cross-env NODE_ENV=production pnpx electron dist/main.js",
"start:dev": "pnpm run start:codepair:dev && pnpm run build && cross-env NODE_ENV=development pnpx electron dist/main.js",
"start:codepair:dev": "cd ../frontend && Pnpm run dev & ",
"electron-builder": "pnpm run build && pnpx electron-builder",
"release": "pnpm run build && pnpx electron-builder --publish always"
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"start:dev": "cross-env NODE_ENV=development electron-forge start",
"start:codepair:dev": "cd ../frontend && pnpm run dev & "
},
"devDependencies": {
"@electron-forge/cli": "^7.2.0",
"@electron-forge/maker-deb": "^7.2.0",
"@electron-forge/maker-rpm": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0",
"@types/node": "^22.7.6",
"cross-env": "^7.0.3",
"electron": "^33.0.1",
"electron-builder": "24.6.4",
"typescript": "^5.3.3"
},
"build": {
"publish": {
"provider": "github",
"releaseType": "draft"
},
"appId": "com.example.codepair",
"productName": "codepair",
"files": [
"dist/**/*",
"node_modules/**/*",
"package.json",
"!node_modules/**/*.{ts,map}",
"!**/*.{iml,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,xproj}",
"!.editorconfig",
"!**/._*",
"!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.flowconfig,.yarn-metadata.json,.idea,appveyor.yml,.travis.yml,circle.yml,npm-debug.log,.nyc_output,yarn.lock,yarn-error.log}"
],
"directories": {
"output": "release"
},
"mac": {
"target": "dmg"
},
"win": {
"target": [
"config": {
"forge": {
"packagerConfig": {
"asar": true
},
"makers": [
{
"target": "nsis",
"arch": [
"x64"
"name": "@electron-forge/maker-squirrel",
"config": {
"name": "codepair"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "@electron-forge/maker-deb",
"config": {}
},
{
"name": "@electron-forge/maker-rpm",
"config": {}
}
],
"publishers": [
{
"name": "@electron-forge/publisher-github",
"config": {
"repository": {
"owner": "minai621",
"name": "codepair"
},
"prerelease": true
}
}
]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"linux": {
"target": "AppImage"
}
}
}

0 comments on commit f2650d1

Please sign in to comment.