Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Electron app setup and release workflow #403

Merged
merged 15 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/desktop-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: desktop-release
on:
release:
types: [published]
minai621 marked this conversation as resolved.
Show resolved Hide resolved

jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: [18.x]

devleejb marked this conversation as resolved.
Show resolved Hide resolved
defaults:
run:
working-directory: ./desktop

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

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

- name: Set up pnpm
uses: pnpm/action-setup@v4

minai621 marked this conversation as resolved.
Show resolved Hide resolved
- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Build and publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm run release
devleejb marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: |
./release/**/*.exe
./release/**/*.dmg
./release/**/*.AppImage
./release/**/*.yml
./release/latest*.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
minai621 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ dist-ssr/
# Tests
coverage/
.nyc_output/

release/
4 changes: 2 additions & 2 deletions backend/tsconfig.json
devleejb marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
"noFallthroughCasesInSwitch": false,
},
}
9 changes: 9 additions & 0 deletions desktop/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"tabWidth": 4,
"useTabs": true,
"printWidth": 100,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true
}
Binary file added desktop/build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions desktop/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import typescriptPlugin from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import prettierPlugin from "eslint-plugin-prettier";

export default [
{
files: ["src/**/*.ts"],
ignores: ["dist", "eslint.config.mjs"],
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: "./tsconfig.json",
},
},
plugins: {
"@typescript-eslint": typescriptPlugin,
prettier: prettierPlugin,
},
rules: {
...typescriptPlugin.configs.recommended.rules,
...prettierPlugin.configs.recommended.rules,
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "error",
},
},
];
67 changes: 67 additions & 0 deletions desktop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "@codepair/desktop",
"type": "module",
"version": "0.1.24",
devleejb marked this conversation as resolved.
Show resolved Hide resolved
"main": "dist/main.js",
"description": "Codepair Desktop",
"author": "yorkie-team",
"repository": {
"type": "git",
"url": "https://github.com/yorkie-team/codepair"
},
"license": "Apache-2.0",
"scripts": {
"start": "pnpm run build-ts && cross-env NODE_ENV=production electron .",
"start:dev": "pnpm run build-ts && cross-env NODE_ENV=development electron .",
"build-ts": "tsc -p tsconfig.json",
"build-electron": "pnpm run build-ts && electron-builder",
"release": "pnpm run build-ts && electron-builder --publish always",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"format": "prettier . --write",
"format:check": "prettier . --check"
},
"devDependencies": {
"@types/node": "^22.9.0",
"cross-env": "^7.0.3",
"electron": "^33.0.1",
"electron-builder": "^25.1.8",
"dotenv": "^16.4.5"
devleejb marked this conversation as resolved.
Show resolved Hide resolved
},
"build": {
"publish": {
"provider": "github"
},
"appId": "com.yorkie-team.codepair",
"productName": "codepair",
"icon": "build/icon.png",
"files": [
"dist/**/*",
"node_modules/**/*",
"package.json",
"!node_modules/**/*.{ts,map}"
],
"directories": {
"output": "release"
},
"mac": {
"target": "dmg"
},
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"linux": {
"target": "AppImage"
}
}
}
41 changes: 41 additions & 0 deletions desktop/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { app, BrowserWindow, dialog } from "electron";

async function createWindow() {
try {
const win = new BrowserWindow({ maximizable: true });
win.maximize();
// In the future, migrate to a proper build tool and environment variable management.
const serviceUrl = "https://codepair.yorkie.dev";

await win.loadURL(serviceUrl);
} catch (error) {
if (error instanceof Error) {
console.error("Error creating the browser window:", error.message);

dialog.showErrorBox(
"Application Error",
`Failed to start application: ${error.message}\n\nThe application will now quit.`
);

app.quit();
}
}
}

app.whenReady().then(createWindow);

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

// Open a window if none are open (macOS)
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
18 changes: 18 additions & 0 deletions desktop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"outDir": "dist",
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],

/* Bundler mode */
"moduleResolution": "node",

/* Linting */
"strict": true
},
"include": ["src"],
"exclude": ["dist"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preinstall": "npx only-allow pnpm",
"frontend": "pnpm --filter=frontend",
"backend": "pnpm --filter=backend",
"desktop": "pnpm --filter=desktop",
"lint": "pnpm run --parallel lint",
"lint:check": "pnpm run --parallel lint:check",
"format": "pnpm run --parallel format",
Expand Down
Loading
Loading