Skip to content

Commit f4994c9

Browse files
author
Fabiana Severin
committed
FIxing build
1 parent 50265d9 commit f4994c9

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

.github/workflows/build-and-release.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,31 @@ jobs:
5454
echo "Building for architecture: $(arch)"
5555
CURRENT_ARCH=$(arch)
5656
57-
# Build native dependencies and JavaScript
57+
# Build native dependencies and JavaScript (this creates dist/node14 and dist/node16)
5858
BUILD=1 npm install
5959
npm run build
6060
61-
# Verify native binary was built
62-
if [ ! -f "build/Release/rapid-client.node" ]; then
63-
echo "Error: Native binary not found at build/Release/rapid-client.node"
61+
# Verify required files were created
62+
if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then
63+
echo "Error: Required files not found in dist directory"
6464
exit 1
6565
fi
6666
67-
# Copy native binary to dist directory
68-
mkdir -p dist
69-
cp build/Release/rapid-client.node dist/
70-
71-
# Create architecture-specific package name
67+
# Copy architecture-specific package.json to dist
7268
node -e "
7369
const pkg = require('./package.json');
7470
pkg.name = 'aws-lambda-ric-' + process.env.CURRENT_ARCH;
75-
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
71+
require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2));
7672
" CURRENT_ARCH=$CURRENT_ARCH
7773
78-
npm pack
74+
# Create tarball with only required files
75+
tar -czf aws-lambda-ric-$CURRENT_ARCH-${{ needs.get-version.outputs.version }}.tgz \
76+
-C dist package.json index.mjs UserFunction.js rapid-client.node
7977
8078
- name: Generate checksums
8179
run: |
82-
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
8380
CURRENT_ARCH=$(arch)
81+
PACKAGE_FILE="aws-lambda-ric-$CURRENT_ARCH-${{ needs.get-version.outputs.version }}.tgz"
8482
sha256sum $PACKAGE_FILE > checksums-$CURRENT_ARCH.sha256
8583
sha512sum $PACKAGE_FILE > checksums-$CURRENT_ARCH.sha512
8684
echo "Package: $PACKAGE_FILE ($CURRENT_ARCH) with version: ${{ needs.get-version.outputs.version }}" > checksums-$CURRENT_ARCH.txt
@@ -90,8 +88,8 @@ jobs:
9088
with:
9189
name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}
9290
path: |
93-
aws-lambda-ric-*.tgz
94-
checksums-*.*
91+
aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz
92+
checksums-*
9593
retention-days: 30
9694

9795
test:
@@ -164,7 +162,7 @@ jobs:
164162
165163
# Publish architecture-specific packages
166164
for arch in x86_64 aarch64; do
167-
PACKAGE_FILE=$(ls ./artifacts/$arch/aws-lambda-ric-*.tgz)
165+
PACKAGE_FILE=$(ls ./artifacts/$arch/aws-lambda-ric-$arch-*.tgz)
168166
echo "Publishing $PACKAGE_FILE for architecture $arch"
169167
npm publish $PACKAGE_FILE $TAG_FLAG --access=public
170168
done
@@ -180,6 +178,6 @@ jobs:
180178
uses: softprops/action-gh-release@v2
181179
with:
182180
files: |
183-
./artifacts/*/aws-lambda-ric-*.tgz
181+
./artifacts/*/aws-lambda-ric-*-*.tgz
184182
combined-checksums.*
185183
prerelease: ${{ steps.version.outputs.is_rc }}

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ build
44
src/*
55
# Rapid-client.c to be used with node-gyp
66
!src/rapid-client.cc
7+
# Include built native binary
8+
!dist/rapid-client.node
79
test
810

911
# Logs

src/build.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,29 @@ const buildOneSet = (target) => {
2828
target,
2929
});
3030

31-
// Keep backward compatibility for Node14
32-
if (process.version.startsWith('v14')) {
33-
build({
34-
...shared,
35-
format: 'cjs',
36-
entryPoints: ['UserFunction.js'],
37-
banner: {
38-
js: '(function (){',
39-
},
40-
footer: {
41-
js: '})();',
42-
},
43-
outfile: `../dist/UserFunction.js`,
44-
target,
45-
});
46-
}
31+
// Always build UserFunction.js
32+
build({
33+
...shared,
34+
format: 'cjs',
35+
entryPoints: ['UserFunction.js'],
36+
banner: {
37+
js: '(function (){',
38+
},
39+
footer: {
40+
js: '})();',
41+
},
42+
outfile: `../dist/UserFunction.js`,
43+
target,
44+
});
45+
46+
// Copy rapid-client
47+
fs.mkdirSync(`../dist`, {
48+
recursive: true,
49+
});
50+
fs.copyFileSync(
51+
'../build/Release/rapid-client.node',
52+
`../dist/rapid-client.node`,
53+
);
4754
};
4855

49-
buildOneSet('node14.21.3');
56+
buildOneSet('node16.20.2');

0 commit comments

Comments
 (0)