Skip to content

Commit 523de7c

Browse files
author
Fabiana Severin
committed
Adding build and publishing for both architectures
1 parent d731168 commit 523de7c

File tree

1 file changed

+71
-45
lines changed

1 file changed

+71
-45
lines changed

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

Lines changed: 71 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,82 +13,108 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
build:
17-
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
18-
timeout-minutes: 15
16+
get-version:
17+
runs-on: ubuntu-latest
1918
outputs:
2019
version: ${{ steps.version.outputs.version }}
2120
steps:
2221
- uses: actions/checkout@v4
23-
24-
- name: Setup Node.js
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: '20'
28-
cache: 'npm'
29-
3022
- name: Get version
3123
id: version
3224
run: |
3325
BASE_VERSION=$(node -p "require('./package.json').version")
3426
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT
27+
28+
build:
29+
needs: [get-version]
30+
timeout-minutes: 30
31+
strategy:
32+
matrix:
33+
include:
34+
- arch: x86_64
35+
runner: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
36+
- arch: aarch64
37+
runner: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
38+
runs-on: ${{ matrix.runner }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: '20'
3546

3647
- name: Install build dependencies
3748
run: |
3849
apt-get update
39-
apt-get install -y cmake make g++
40-
41-
- name: Clean and build
50+
apt-get install -y cmake make g++ autotools-dev automake libtool
51+
52+
- name: Build natively for $(arch)
4253
run: |
43-
rm -rf deps/*/build
44-
npm ci
54+
echo "Building for architecture: $(arch)"
55+
BUILD=1 npm install
4556
npm run build
4657
npm pack
4758
4859
- name: Generate checksums
4960
run: |
5061
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
51-
sha256sum $PACKAGE_FILE > checksums.sha256
52-
sha512sum $PACKAGE_FILE > checksums.sha512
53-
cat checksums.sha256 checksums.sha512 > checksums.txt
54-
echo "Package: $PACKAGE_FILE with version: ${{ steps.version.outputs.version }}" >> checksums.txt
62+
CURRENT_ARCH=$(arch)
63+
sha256sum $PACKAGE_FILE > checksums-$CURRENT_ARCH.sha256
64+
sha512sum $PACKAGE_FILE > checksums-$CURRENT_ARCH.sha512
65+
echo "Package: $PACKAGE_FILE ($CURRENT_ARCH) with version: ${{ needs.get-version.outputs.version }}" > checksums-$CURRENT_ARCH.txt
5566
5667
- name: Upload artifacts
5768
uses: actions/upload-artifact@v4
5869
with:
59-
name: package-${{ steps.version.outputs.version }}
70+
name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}
6071
path: |
6172
aws-lambda-ric-*.tgz
62-
checksums.*
73+
checksums-*.*
6374
retention-days: 30
6475

6576
test:
66-
runs-on: ubuntu-latest
67-
needs: [build]
77+
needs: [get-version, build]
6878
strategy:
6979
matrix:
7080
node-version: [18, 20, 22]
81+
include:
82+
- arch: x86_64
83+
runner: ubuntu-latest
84+
- arch: aarch64
85+
runner: ubuntu-latest
86+
runs-on: ${{ matrix.runner }}
7187
steps:
7288
- uses: actions/checkout@v4
7389

74-
- name: Run unit tests - Node ${{ matrix.node-version }}
90+
- name: Run unit tests - Node ${{ matrix.node-version }} (native $(arch))
7591
run: |
76-
docker build -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x -t unit/nodejs.${{ matrix.node-version }}x .
92+
docker build \
93+
-f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x \
94+
-t unit/nodejs.${{ matrix.node-version }}x \
95+
.
7796
docker run --rm unit/nodejs.${{ matrix.node-version }}x
7897
7998
publish:
8099
if: startsWith(github.ref, 'refs/tags/')
81100
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
82-
needs: [build, test]
101+
needs: [get-version, build, test]
83102
permissions:
84103
contents: write
85104
steps:
86105
- uses: actions/checkout@v4
87106

88-
- name: Download artifacts
107+
- name: Download x86_64 artifacts
108+
uses: actions/download-artifact@v4
109+
with:
110+
name: package-x86_64-${{ needs.get-version.outputs.version }}
111+
path: ./artifacts/x86_64
112+
113+
- name: Download aarch64 artifacts
89114
uses: actions/download-artifact@v4
90115
with:
91-
name: package-${{ needs.build.outputs.version }}
116+
name: package-aarch64-${{ needs.get-version.outputs.version }}
117+
path: ./artifacts/aarch64
92118

93119
- name: Setup Node.js
94120
uses: actions/setup-node@v4
@@ -101,37 +127,37 @@ jobs:
101127
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
102128
chmod 0600 .npmrc
103129
104-
- name: Determine version and package name
130+
- name: Determine version and publish packages
105131
id: version
106132
run: |
107133
if [[ "${{ github.ref }}" == refs/tags/rc-* ]]; then
108134
RC_NUMBER=${GITHUB_REF#refs/tags/rc-}
109-
PACKAGE_VERSION="${{ needs.build.outputs.version }}-rc.${RC_NUMBER}"
135+
PACKAGE_VERSION="${{ needs.get-version.outputs.version }}-rc.${RC_NUMBER}"
110136
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
111137
echo "is_rc=true" >> $GITHUB_OUTPUT
112-
npm version $PACKAGE_VERSION --no-git-tag-version
138+
TAG_FLAG="--tag rc"
113139
else
114-
echo "package_version=${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT
115-
npm version ${{ needs.build.outputs.version }} --no-git-tag-version
140+
echo "package_version=${{ needs.get-version.outputs.version }}" >> $GITHUB_OUTPUT
141+
TAG_FLAG=""
116142
fi
117-
npm pack
143+
144+
# Publish both architecture packages
145+
for arch in x86_64 aarch64; do
146+
PACKAGE_FILE=$(ls ./artifacts/$arch/aws-lambda-ric-*.tgz)
147+
npm publish $PACKAGE_FILE $TAG_FLAG --access=public
148+
done
118149
119-
- name: Publish to npm
150+
- name: Combine checksums
120151
run: |
121-
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
122-
if [[ "${{ steps.version.outputs.is_rc }}" == "true" ]]; then
123-
npm publish $PACKAGE_FILE --tag rc --access=public
124-
else
125-
npm publish $PACKAGE_FILE --access=public
126-
fi
152+
cat ./artifacts/*/checksums-*.txt > combined-checksums.txt
153+
cat ./artifacts/*/checksums-*.sha256 > combined-checksums.sha256
154+
cat ./artifacts/*/checksums-*.sha512 > combined-checksums.sha512
127155
128156
- name: Create GitHub Release
129157
if: startsWith(github.ref, 'refs/tags/')
130158
uses: softprops/action-gh-release@v2
131159
with:
132160
files: |
133-
aws-lambda-ric-*.tgz
134-
checksums.sha256
135-
checksums.sha512
136-
checksums.txt
161+
./artifacts/*/aws-lambda-ric-*.tgz
162+
combined-checksums.*
137163
prerelease: ${{ steps.version.outputs.is_rc }}

0 commit comments

Comments
 (0)