diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 70adfd3a..4b58af06 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -1,4 +1,4 @@ -name: electron-windows-nsis-build +name: Build and Publish Electron App on: push: @@ -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 electron-builder@24.6.4 - - - 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 diff --git a/native/package.json b/native/package.json index 42cb9a7a..9899fe2d 100644 --- a/native/package.json +++ b/native/package.json @@ -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" } } }