Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
59 changes: 59 additions & 0 deletions .github/workflows/build-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Testing build on commit"

on:
push:

jobs:
compilation:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24

- name: Get utils
run: sudo apt install -y qemu-user-binfmt

- uses: MOZGIII/install-ldid-action@v1
with:
tag: v2.1.5-procursus7

- name: Install npm modules
run: npm i

- name: Package application
run: npm run build:executable

# Publish

- name: Export release for Linux
uses: actions/upload-artifact@v4
with:
name: linux-compiled-archive
if-no-files-found: error
compression-level: 0
overwrite: true
path: |
${{ github.workspace }}/bin/simple-linux*

- name: Export release for Windows
uses: actions/upload-artifact@v4
with:
name: windows-compiled-archive
if-no-files-found: error
compression-level: 0
overwrite: true
path: |
${{ github.workspace }}/bin/simple-win*

- name: Export release for MacOS
uses: actions/upload-artifact@v4
with:
name: macos-compiled-archive
if-no-files-found: error
compression-level: 0
overwrite: true
path: |
${{ github.workspace }}/bin/simple-macos*
49 changes: 49 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Releasing with compressed binary"

on:
workflow_call:

jobs:
compilation:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24

- name: Get utils
run: sudo apt install -y qemu-user-binfmt

- uses: MOZGIII/install-ldid-action@v1
with:
tag: v2.1.5-procursus7

- name: Install npm modules
run: npm i

- name: Get release metadata
id: setup_new_release_data
run: |
date=$(date +'%d/%m/%y %R')
echo "date=$date" >> "$GITHUB_OUTPUT"

- name: Package application
run: npm run build:executable-compressed

# Publish

- name: Publish alpha to Github
uses: softprops/action-gh-release@v2
with:
prerelease: true
make_latest: false
tag_name: "alpha"
name: Alpha Version
body: |
Alpha release of the SIMPLE webplatform. Please test and report issues.
Lastly updated on $(date +'%d/%m/%y %R').
generate_release_notes: true
files: ${{ github.workspace }}/bin/*
fail_on_unmatched_files: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ dist-ssr
package-lock.json
errorLog.log*
learning-packages/ACROSS-Lab QuangBinhProject MIAT-version Gama/

# Compilation related
bin
dist
dist-api
36 changes: 36 additions & 0 deletions BUILD_EXECUTABLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### Building the Executable

To package this application into a single Linux executable, follow these steps:

1. **Install dependencies**:
```bash
npm install
```

2. **Build the executable**:
```bash
npm run build:executable
```
This command will:
- Build the Vite frontend into the `dist` folder.
- Bundle the Node.js backend into `dist-api/index.cjs` using Vite (handling TypeScript and ESM conversion).
- Package everything into a single binary located in the `bin` directory using `@yao-pkg/pkg`.

### Distribution

The generated executables are located in the `bin/` directory.

**Requirements for running**:
- **Operating System**: Linux (x64) or Windows (x64).
- **External Configuration**: The application expects a `.env` file to be present in the **same directory** as the executable.
- **Dependencies**: No Node.js installation is required. However, the application still relies on `adb` being installed on the host system if Android device management is needed.

### Technical Details

- **Packaging Tool**: `@yao-pkg/pkg` (a maintained fork of `pkg` that supports Node >=20).
- **Backend Bundling**: Vite is used to bundle the backend. This ensures that:
- All TypeScript files and ESM imports are resolved.
- Dependencies are bundled into a single file to avoid issues with subpath imports or complex `node_modules` structures in the packaged environment.
- Native modules (like `uWebSockets.js`) are kept external and included as assets.
- **Static Files**: The Vite-built frontend is bundled into the executable and served via an Express server integrated into the backend when running in packaged mode.
- **Environment Variables**: `dotenv` is configured to look for the `.env` file in the directory of the executable (`process.execPath`).
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default tseslint.config({
rules: {
"@typescript-eslint/no-explicit-any": "error"
}
});
Loading