Skip to content

Commit 8582b86

Browse files
authored
Merge pull request #3 from ASLS-org/staging
feat: setup server binaries generation
2 parents 162a8a0 + 0c18f3b commit 8582b86

7 files changed

Lines changed: 4279 additions & 6351 deletions

File tree

.github/workflows/release.yml

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,122 @@ on:
55
branches: [main, staging]
66

77
jobs:
8+
build:
9+
strategy:
10+
matrix:
11+
include:
12+
- os: ubuntu-latest
13+
target: node18-linux-x64
14+
15+
- os: windows-latest
16+
target: node18-win-x64
17+
18+
- os: macos-latest
19+
target: node18-macos-arm64
20+
21+
runs-on: ${{ matrix.os }}
22+
23+
permissions:
24+
contents: write
25+
26+
steps:
27+
# ----------------------------
28+
# Checkout
29+
# ----------------------------
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
# ----------------------------
35+
# Node
36+
# ----------------------------
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version: 20
40+
registry-url: https://registry.npmjs.org
41+
cache: npm
42+
43+
# ----------------------------
44+
# Install
45+
# ----------------------------
46+
- run: npm ci
47+
48+
# ----------------------------
49+
# Ensure correct wrtc native binary
50+
# ----------------------------
51+
- run: npm rebuild @roamhq/wrtc
52+
working-directory: ./implementations/js/server
53+
54+
# ----------------------------
55+
# Build
56+
# ----------------------------
57+
- run: npm run build
58+
59+
# ----------------------------
60+
# Package
61+
# ----------------------------
62+
- name: Package server
63+
run: npx pkg . --targets ${{ matrix.target }} --output ./dist/bin/wsc-server-${{ matrix.target }}
64+
working-directory: ./implementations/js/server
65+
# ----------------------------
66+
# macOS ad-hoc signing
67+
# ----------------------------
68+
- name: Codesign macOS binary
69+
if: matrix.os == 'macos-latest'
70+
run: |
71+
find ./implementations/js/server/dist/bin -type f -exec codesign --force --deep --sign - {} \;
72+
73+
# ----------------------------
74+
# Upload artifacts
75+
# ----------------------------
76+
- name: Upload artifacts
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: build-${{ matrix.target }}
80+
path: ./implementations/js/server/dist/bin/*
81+
882
release:
83+
needs: build
84+
985
runs-on: ubuntu-latest
1086

1187
permissions:
1288
contents: write
1389

1490
steps:
91+
# ----------------------------
92+
# Checkout
93+
# ----------------------------
1594
- uses: actions/checkout@v4
1695
with:
1796
fetch-depth: 0
1897

98+
# ----------------------------
99+
# Node
100+
# ----------------------------
19101
- uses: actions/setup-node@v4
20102
with:
21103
node-version: 20
22104
registry-url: https://registry.npmjs.org
105+
cache: npm
23106

24-
- run: npm install
107+
# ----------------------------
108+
# Install
109+
# ----------------------------
110+
- run: npm ci
25111

26-
- run: npm run build
112+
# ----------------------------
113+
# Restore binaries EXACTLY where semantic-release expects them
114+
# ----------------------------
115+
- name: Download artifacts
116+
uses: actions/download-artifact@v4
117+
with:
118+
path: ./implementations/js/server/dist/bin
119+
merge-multiple: true
27120

121+
# ----------------------------
122+
# Release
123+
# ----------------------------
28124
- name: Release
29125
run: npx semantic-release
30126
env:

bindings/js/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"os": [
1414
"darwin",
1515
"linux",
16-
"windows"
16+
"win32"
1717
],
1818
"main": "./src/main.js",
1919
"exports": {

implementations/js/client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
},
99
"description": "ASLS's WSC (Web Show Control) client",
1010
"engines": {
11-
"node": ">=20"
11+
"node": "18"
1212
},
1313
"os": [
1414
"darwin",
1515
"linux",
16-
"windows"
16+
"win32"
1717
],
1818
"main": "src/main.js",
1919
"exports": {

implementations/js/server/package.json

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
11
{
22
"version": "1.0.0",
33
"name": "@asls/wsc-server",
4-
"type": "module",
54
"private": false,
5+
"type": "module",
66
"publishConfig": {
77
"access": "public"
88
},
99
"description": "ASLS's WSC (Web Show Control) server",
1010
"engines": {
11-
"node": ">=20"
11+
"node": "18"
1212
},
1313
"os": [
1414
"darwin",
1515
"linux",
16-
"windows"
16+
"win32"
1717
],
18-
"main": "./dist/server.js",
18+
"bin": "./dist/main.cjs",
19+
"pkg": {
20+
"scripts": "dist/**/*.cjs",
21+
"assets": [
22+
"../../../node_modules/@roamhq/**/*"
23+
],
24+
"options": {
25+
"no-bytecode": true,
26+
"public-packages": "*"
27+
},
28+
"outputPath": "./dist/bin"
29+
},
30+
"main": "./dist/main.cjs",
1931
"exports": {
20-
".": "./dist/server.js"
32+
".": "./dist/main.cjs"
2133
},
2234
"files": [
23-
"dist"
35+
"dist/**/*.cjs",
36+
"dist/package.json"
2437
],
2538
"scripts": {
2639
"test": "echo \"Error: no test specified\" && exit 1",
2740
"dev": "tsx watch ./src/main.js",
28-
"start": "node ./src/main.js",
29-
"build": "node ./src/scripts/build.js"
41+
"start": "node ./dist/main.cjs",
42+
"build": "node ./src/scripts/build.js",
43+
"pkg": "npx pkg ."
3044
},
3145
"author": "Timé Kadel",
3246
"license": "GPL-3.0-only",

implementations/js/server/src/scripts/build.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ async function run() {
1414
console.log('⚡ Building server...');
1515

1616
await build({
17-
entryPoints: ['./src/server.js'],
18-
outfile: './dist/server.js',
17+
entryPoints: ['./src/main.js'],
18+
outfile: './dist/main.cjs',
1919
bundle: true,
2020
platform: 'node',
2121
target: 'node20',
22-
format: 'esm',
23-
external: [
24-
'@roamhq/wrtc',
25-
'systeminformation',
26-
],
22+
format: 'cjs',
23+
// external: [
24+
// '@roamhq/wrtc',
25+
// 'systeminformation',
26+
// ],
2727
});
2828

2929
console.log('📄 Updating package.json...');
@@ -32,9 +32,9 @@ async function run() {
3232
await readFile('./package.json', 'utf-8'),
3333
);
3434

35-
pkg.main = './server.js';
35+
pkg.main = './main.js';
3636
pkg.exports = {
37-
'.': './server.js',
37+
'.': './main.js',
3838
};
3939

4040
await writeFile(

0 commit comments

Comments
 (0)