Skip to content

Commit 0f269b8

Browse files
committed
New release script for individual binary installs
1 parent 14bb3af commit 0f269b8

File tree

3 files changed

+86
-7
lines changed

3 files changed

+86
-7
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Update binaries
1414
run: |
1515
$ErrorActionPreference = 'SilentlyContinue'
16-
git clone --recursive https://github.com/uNetworking/uWebSockets.js.git
16+
git clone --recursive https://github.com/${{ github.repository }}.git
1717
cd uWebSockets.js
1818
nmake
1919
git fetch origin binaries:binaries
@@ -23,7 +23,7 @@ jobs:
2323
git config --global user.email "[email protected]"
2424
git config --global user.name "Alex Hultman"
2525
git commit -a -m "[GitHub Actions] Updated windows-latest binaries"
26-
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" binaries
26+
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/${{ github.repository }}" binaries
2727
git checkout master -- tests/smoke.js
2828
npm install ws
2929
node tests/smoke.js
@@ -39,7 +39,7 @@ jobs:
3939
sudo apt update || true
4040
brew install go || true
4141
sudo apt install -y g++-aarch64-linux-gnu || true
42-
git clone --recursive https://github.com/uNetworking/uWebSockets.js.git
42+
git clone --recursive https://github.com/${{ github.repository }}.git
4343
cd uWebSockets.js
4444
make
4545
git fetch origin binaries:binaries
@@ -52,7 +52,7 @@ jobs:
5252
git config --global user.email "[email protected]"
5353
git config --global user.name "Alex Hultman"
5454
git commit -a -m "[GitHub Actions] Updated ${{ matrix.os }} binaries" || true
55-
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" binaries
55+
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/${{ github.repository }}" binaries
5656
git checkout master -- tests/smoke.js
5757
npm install ws
5858
node tests/smoke.js
@@ -66,7 +66,7 @@ jobs:
6666
os: ubuntu20.04
6767
steps:
6868
- name: Clone
69-
run: git clone --recursive https://github.com/uNetworking/uWebSockets.js.git
69+
run: git clone --recursive https://github.com/${{ github.repository }}.git
7070
- uses: uraimo/[email protected]
7171
name: Compile binaries
7272
with:
@@ -94,4 +94,4 @@ jobs:
9494
git config --global user.name "Alex Hultman"
9595
git add *.node *.js
9696
git commit -a -m "[GitHub Actions] Updated linux-${{ matrix.arch }} binaries" || true
97-
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" binaries
97+
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/${{ github.repository }}" binaries

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number for the new release'
8+
required: true
9+
10+
jobs:
11+
release:
12+
if: github.event_name == 'workflow_dispatch'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Release new version
16+
run: |
17+
git config --global user.email "[email protected]"
18+
git config --global user.name "Alex Hultman"
19+
git clone --branch binaries --single-branch --depth 1 https://github.com/${{ github.repository }}.git
20+
cd uWebSockets.js
21+
22+
version="${{ github.event.inputs.version }}"
23+
binaries=($(find . -type f -name "*.node" -exec basename {} .node \;))
24+
25+
declare -A abi_map=(
26+
["108"]="18.x"
27+
["115"]="20.x"
28+
["120"]="21.x"
29+
["127"]="22.x"
30+
["131"]="23.x"
31+
)
32+
33+
for binary in "${binaries[@]}"; do
34+
IFS='_' read -r os cpu abi <<< "${binary#uws_}"
35+
node_version="${abi_map[$abi]}"
36+
37+
echo '{
38+
"name": "@uws/'"$binary"'",
39+
"version": "'"${version}"'",
40+
"main": "uws.js",
41+
"os": ["'"$os"'"],
42+
"cpu": ["'"$cpu"'"],
43+
"engines": {
44+
"node": "'"$node_version"'"
45+
}
46+
}' > package.json
47+
48+
echo 'module.exports = require("./'"$binary"'.node")' > uws.js
49+
50+
rm ESM_wrapper.mjs index.d.ts
51+
find . -name '*.node' ! -name "${binary}.node" -exec rm -f {} +
52+
53+
git checkout --detach
54+
git add -A
55+
git commit -m "Released @uws/$binary with version $version"
56+
git tag "v${version}-$binary"
57+
git push "https://x-access-token:${{ secrets.SECRET }}@github.com/${{ github.repository }}" "v${version}-$binary"
58+
git checkout binaries
59+
done
60+
61+
rm -rf *.node
62+
63+
deps=""
64+
for binary in "${binaries[@]}"; do
65+
deps+="\"@uws/$binary\": \"github:porsager/uWebSockets.js#v${version}-$binary\",\n "
66+
done
67+
deps=${deps%,*}
68+
69+
sed -i "s|\"optionalDependencies\": {}|\"optionalDependencies\": {\n $deps\n}|" package.json
70+
sed -i "s|\"version\": \"[^\"]*\"|\"version\": \"${version}\"|g" package.json
71+
sed -i "s|./uws_|@uws/uws_|g" uws.js
72+
73+
git checkout --detach
74+
git add package.json
75+
git add *.node
76+
git commit -m "Release $version"
77+
78+
git tag "v$version"
79+
git push "https://x-access-token:${{ secrets.SECRET }}@github.com/${{ github.repository }}" "v$version"

src/uws.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
module.exports = (() => {
1919
try {
20-
return require('./uws_' + process.platform + '_' + process.arch + '_' + process.versions.modules + '.node');
20+
return require('./uws_' + process.platform + '_' + process.arch + '_' + process.versions.modules);
2121
} catch (e) {
2222
throw new Error('This version of uWS.js (v20.51.0) supports only Node.js versions 18, 20, 22 and 23 on (glibc) Linux, macOS and Windows, on Tier 1 platforms (https://github.com/nodejs/node/blob/master/BUILDING.md#platform-list).\n\n' + e.toString());
2323
}

0 commit comments

Comments
 (0)