Skip to content

Commit 1c7f67f

Browse files
build: adding workflows for node linux builds and script to bundle them in a way usable for our internal systems
1 parent 084d761 commit 1c7f67f

File tree

4 files changed

+264
-1
lines changed

4 files changed

+264
-1
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build node-fibers with prebuilt Node
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: [Build Node]
7+
types:
8+
- completed
9+
10+
jobs:
11+
build-fibers:
12+
strategy:
13+
matrix:
14+
include:
15+
- platform: linux
16+
arch: x64
17+
runs_on: ubuntu-22.04
18+
- platform: linux
19+
arch: arm64
20+
runs_on: ubuntu-22.04-arm
21+
runs-on: ${{ matrix.runs_on }}
22+
23+
env:
24+
NODE_VERSION: v20.18.3
25+
26+
steps:
27+
- name: Debug Matrix Values
28+
run: |
29+
echo "Matrix platform: ${{ matrix.platform }}"
30+
echo "Matrix arch: ${{ matrix.arch }}"
31+
32+
- name: Download Node archive
33+
run: |
34+
gh release download node-${{ env.NODE_VERSION }}-release \
35+
--repo asana/node \
36+
--pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz"
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract Node archive
41+
run: |
42+
mkdir -p node-install
43+
tar -C node-install -xJf node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz
44+
echo "$GITHUB_WORKSPACE/node-install/usr/local/bin" >> $GITHUB_PATH
45+
46+
- name: Verify Node Binary Architecture
47+
run: |
48+
echo "Node File:"
49+
file $GITHUB_WORKSPACE/node-install/usr/local/bin/node
50+
echo "Runner architecture:"
51+
uname -m
52+
53+
- name: Checkout node-fibers fork
54+
uses: actions/checkout@v3
55+
with:
56+
repository: asana/node-fibers
57+
ref: jackstrohm_node20_fibers
58+
path: node-fibers
59+
60+
- name: Build node-fibers
61+
working-directory: node-fibers
62+
run: |
63+
which node
64+
node -v
65+
node -p "process.arch"
66+
npm install --nodedir="$GITHUB_WORKSPACE/node-install/usr/local"
67+
npm test || true
68+
rm bin/repl
69+
find .
70+
71+
- name: Find and archive fibers.node
72+
run: |
73+
# Find the directory under bin/ that contains fibers.node
74+
FIBERS_PATH=$(find ./node-fibers/bin -type f -name fibers.node | head -n1)
75+
FIBERS_DIR=$(dirname "$FIBERS_PATH")
76+
ARCHIVE_NAME=$(basename "$FIBERS_DIR").tar.gz
77+
echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $GITHUB_ENV
78+
tar -czf "$ARCHIVE_NAME" -C "$(dirname "$FIBERS_DIR")" "$(basename "$FIBERS_DIR")"
79+
80+
- name: Upload archive to release
81+
uses: softprops/action-gh-release@v1
82+
with:
83+
name: node-${{ env.NODE_VERSION }}-LATEST
84+
tag_name: node-${{ env.NODE_VERSION }}-release
85+
files: ${{ env.ARCHIVE_NAME }}
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-node.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build Node
2+
3+
on:
4+
push:
5+
branches:
6+
- v20.18.3
7+
- workflows-for-v20.18.3
8+
pull_request:
9+
paths: .github/workflows/build-node.yml
10+
11+
jobs:
12+
build-node:
13+
name: Build ${{ matrix.platform }}-${{ matrix.arch }}
14+
strategy:
15+
matrix:
16+
include:
17+
- platform: linux
18+
arch: x64
19+
runs_on: ubuntu-22.04
20+
- platform: linux
21+
arch: arm64
22+
runs_on: ubuntu-22.04-arm
23+
runs-on: ${{ matrix.runs_on }}
24+
25+
env:
26+
S3_BUCKET: your-bucket-name
27+
AWS_REGION: us-east-1
28+
29+
steps:
30+
- name: Checkout Node fork
31+
uses: actions/checkout@v3
32+
with:
33+
repository: Asana/node
34+
path: node
35+
ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.ref_name }}
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract Node Version
39+
id: extract-node-version
40+
run: |
41+
NODE_MAJOR_VERSION=$(grep '#define NODE_MAJOR_VERSION' node/src/node_version.h | awk '{print $3}')
42+
NODE_MINOR_VERSION=$(grep '#define NODE_MINOR_VERSION' node/src/node_version.h | awk '{print $3}')
43+
NODE_PATCH_VERSION=$(grep '#define NODE_PATCH_VERSION' node/src/node_version.h | awk '{print $3}')
44+
NODE_VERSION="v${NODE_MAJOR_VERSION}.${NODE_MINOR_VERSION}.${NODE_PATCH_VERSION}"
45+
echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV
46+
47+
- name: Set build metadata
48+
id: meta
49+
working-directory: node
50+
run: |
51+
TIMESTAMP=$(date -u +%Y-%m-%dT%H-%M)
52+
SHORT_SHA=$(git rev-parse --short HEAD)
53+
echo "BUILD_ID=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_ENV
54+
echo "build_id=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT
55+
56+
- name: Install dependencies (Linux)
57+
if: matrix.platform == 'linux'
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y python3 g++ make curl tar xz-utils
61+
62+
- name: Build Node (linux)
63+
working-directory: node
64+
if: matrix.platform == 'linux'
65+
run: |
66+
./configure --experimental-enable-pointer-compression
67+
make -j4 install DESTDIR=$GITHUB_WORKSPACE/node-install
68+
69+
- name: Build Node (darwin)
70+
working-directory: node
71+
if: matrix.platform == 'darwin'
72+
run: |
73+
./configure --experimental-enable-pointer-compression --without-snapshot
74+
make -j2 install DESTDIR=$GITHUB_WORKSPACE/node-install
75+
76+
- name: Archive Node
77+
run: |
78+
mkdir -p artifacts
79+
FILENAME=node-${NODE_VERSION}-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}.tar.xz
80+
FILENAME_LATEST=node-${NODE_VERSION}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz
81+
tar -C node-install -cJf artifacts/$FILENAME .
82+
cp artifacts/$FILENAME artifacts/$FILENAME_LATEST
83+
echo "NODE_ARCHIVE=$FILENAME" >> $GITHUB_ENV
84+
echo "NODE_ARCHIVE_LATEST=$FILENAME_LATEST" >> $GITHUB_ENV
85+
86+
- name: Upload Node archive
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}
90+
path: artifacts/${{ env.NODE_ARCHIVE }}
91+
92+
- name: Upload Node archive latest
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST
96+
path: artifacts/${{ env.NODE_ARCHIVE_LATEST }}
97+
98+
- name: Upload Node archive to release
99+
uses: softprops/action-gh-release@v1
100+
with:
101+
name: node-${{ env.NODE_VERSION }}-LATEST
102+
tag_name: node-${{ env.NODE_VERSION }}-release
103+
files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }}
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

stage_for_s3.bash

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir stage
4+
cd stage || exit
5+
6+
TIMESTAMP=$(date '+%Y%m%d.%H%M')
7+
8+
echo "Current timestamp is $TIMESTAMP"
9+
10+
gh release download -p "*.gz"
11+
gh release download -p "*.xz"
12+
13+
curl "https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz
14+
tar -xzf fibers-5.0.4.tar.gz
15+
16+
find . -name "*.gz" | while read -r a
17+
do
18+
tar -xzf "$a" -C package/bin
19+
rm "$a"
20+
done
21+
22+
tar -czf temp.tgz package/
23+
rm -fr package
24+
SHORT_HASH=$(cat temp.tgz | sha1sum | cut -c1-4)
25+
echo "HASH: $SHORT_HASH"
26+
UNIQUE="pc-${TIMESTAMP}-${SHORT_HASH}"
27+
28+
mv temp.tgz "fibers-5.0.4-${UNIQUE}.tgz"
29+
30+
for file in *.tar.xz; do
31+
if [[ "$file" == *-LATEST.tar.xz ]]; then
32+
base="${file%-LATEST.tar.xz}"
33+
new_name="${base}-${UNIQUE}.tar.xz"
34+
35+
echo "Renaming: $file -> $new_name"
36+
mv "$file" "$new_name"
37+
38+
if [[ "$new_name" =~ node-v([0-9.]+)-(darwin|linux)-(arm64|x64)-pc.*\.tar\.xz$ ]]; then
39+
version="${BASH_REMATCH[1]}"
40+
os="${BASH_REMATCH[2]}"
41+
arch="${BASH_REMATCH[3]}"
42+
target_dir="node-v${version}-${os}-${arch}"
43+
44+
echo "Target Dir: $target_dir"
45+
mkdir "$target_dir"
46+
tar -xzf "$new_name" -C "$target_dir"
47+
mv "$target_dir/usr/local/*" "$target_dir"
48+
rm -fr "$target_dir/usr/local"
49+
50+
tar -cJf "$new_name" "$target_dir"
51+
52+
rm -fr "$target_dir"
53+
54+
echo "✅ Done: Archive now contains:"
55+
tar -tf "$new_name" | head
56+
57+
else
58+
echo "Warning: Skipped $new_name due to unexpected filename format."
59+
fi
60+
fi
61+
done
62+
63+
64+
cd ..
65+
mv stage "node-${UNIQUE}"
66+
67+
echo "Files are in node-${UNIQUE}, please upload to s3"
68+
69+
70+

tools/dep_updaters/update-openssl.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ main() {
174174
* )
175175
echo "unknown command: $1"
176176
help 1
177-
exit 1
177+
# shellcheck disable=SC2317
178+
exit 1
178179
;;
179180
esac
180181
}

0 commit comments

Comments
 (0)