Skip to content

Commit 8170ee6

Browse files
author
Severin
committed
Split build and release workflows
1 parent f45fccb commit 8170ee6

File tree

2 files changed

+136
-38
lines changed

2 files changed

+136
-38
lines changed

.github/workflows/build.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions: {}
10+
11+
jobs:
12+
get-version:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
outputs:
17+
version: ${{ steps.version.outputs.version }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Get version
21+
id: version
22+
run: |
23+
BASE_VERSION=$(node -p "require('./package.json').version")
24+
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT
25+
26+
build:
27+
needs: [get-version]
28+
timeout-minutes: 30
29+
permissions:
30+
id-token: write
31+
contents: read
32+
strategy:
33+
matrix:
34+
include:
35+
- arch: x86_64
36+
runner: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
37+
- arch: aarch64
38+
runner: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
39+
runs-on: ${{ matrix.runner }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: 'lts/*'
47+
48+
- name: Check copyright headers
49+
run: npm run check-headers
50+
51+
- name: Install build dependencies
52+
run: |
53+
apt-get update
54+
apt-get install -y cmake make g++ autotools-dev automake libtool
55+
56+
- name: Build natively for ${{ matrix.arch }}
57+
run: |
58+
echo "Building for architecture: ${{ matrix.arch }}"
59+
60+
# Build native dependencies and JavaScript
61+
BUILD=1 npm install
62+
npm run build
63+
64+
# Verify required files were created
65+
if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then
66+
echo "Error: Required files not found in dist directory"
67+
exit 1
68+
fi
69+
70+
# Copy architecture-specific package.json to dist
71+
node -e "
72+
const pkg = require('./package.json');
73+
pkg.name = 'aws-lambda-ric-${{ matrix.arch }}';
74+
require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2));
75+
"
76+
77+
# Create tarball with only required files
78+
tar -czf aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz \
79+
-C dist package.json index.mjs UserFunction.js rapid-client.node
80+
81+
- name: Generate checksums
82+
run: |
83+
PACKAGE_FILE="aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz"
84+
sha256sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha256
85+
sha512sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha512
86+
echo "Package: $PACKAGE_FILE (${{ matrix.arch }}) with version: ${{ needs.get-version.outputs.version }}" > checksums-${{ matrix.arch }}.txt
87+
88+
- name: Upload artifacts
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}
92+
path: |
93+
aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz
94+
checksums-*
95+
retention-days: 30
96+
97+
test:
98+
needs: [get-version, build]
99+
permissions:
100+
contents: read
101+
strategy:
102+
matrix:
103+
node-version: [18, 20, 22]
104+
include:
105+
- arch: x86_64
106+
runner: ubuntu-latest
107+
- arch: aarch64
108+
runner: ubuntu-latest
109+
runs-on: ${{ matrix.runner }}
110+
steps:
111+
- uses: actions/checkout@v4
112+
113+
- name: Run unit tests - Node ${{ matrix.node-version }} (native $(arch))
114+
run: |
115+
docker build \
116+
-f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x \
117+
-t unit/nodejs.${{ matrix.node-version }}x \
118+
.
119+
docker run --rm unit/nodejs.${{ matrix.node-version }}x

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

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Build and Release
1+
name: Release
22

33
on:
4-
push:
5-
branches: [ main ]
6-
tags: [ 'v*', 'rc-*' ]
7-
pull_request:
8-
branches: [ main ]
94
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Release tag (e.g., v1.0.0 or rc-1)'
8+
required: true
9+
type: string
1010

1111
permissions: {}
1212

@@ -47,9 +47,6 @@ jobs:
4747
with:
4848
node-version: 'lts/*'
4949

50-
- name: Check copyright headers
51-
run: npm run check-headers
52-
5350
- name: Install build dependencies
5451
run: |
5552
apt-get update
@@ -96,34 +93,9 @@ jobs:
9693
checksums-*
9794
retention-days: 30
9895

99-
test:
100-
needs: [get-version, build]
101-
permissions:
102-
contents: read
103-
strategy:
104-
matrix:
105-
node-version: [18, 20, 22]
106-
include:
107-
- arch: x86_64
108-
runner: ubuntu-latest
109-
- arch: aarch64
110-
runner: ubuntu-latest
111-
runs-on: ${{ matrix.runner }}
112-
steps:
113-
- uses: actions/checkout@v4
114-
115-
- name: Run unit tests - Node ${{ matrix.node-version }} (native $(arch))
116-
run: |
117-
docker build \
118-
-f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x \
119-
-t unit/nodejs.${{ matrix.node-version }}x \
120-
.
121-
docker run --rm unit/nodejs.${{ matrix.node-version }}x
122-
12396
publish:
124-
if: startsWith(github.ref, 'refs/tags/')
12597
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
126-
needs: [get-version, build, test]
98+
needs: [get-version, build]
12799
permissions:
128100
id-token: write
129101
contents: write
@@ -153,10 +125,17 @@ jobs:
153125
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
154126
chmod 0600 .npmrc
155127
128+
- name: Create and push tag
129+
run: |
130+
git config --global user.name "github-actions[bot]"
131+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
132+
git tag ${{ inputs.tag }}
133+
git push origin ${{ inputs.tag }}
134+
156135
- name: Determine version and publish packages
157136
id: version
158137
run: |
159-
if [[ "${{ github.ref }}" == refs/tags/rc-* ]]; then
138+
if [[ "${{ inputs.tag }}" == rc-* ]]; then
160139
RC_NUMBER=${GITHUB_REF#refs/tags/rc-}
161140
PACKAGE_VERSION="${{ needs.get-version.outputs.version }}-rc.${RC_NUMBER}"
162141
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
@@ -179,10 +158,10 @@ jobs:
179158
cat ./artifacts/*/checksums-*.sha512 > combined-checksums.sha512
180159
181160
- name: Create GitHub Release
182-
if: startsWith(github.ref, 'refs/tags/')
183161
uses: softprops/action-gh-release@v2
184162
with:
163+
tag_name: ${{ inputs.tag }}
185164
files: |
186165
./artifacts/*/aws-lambda-ric-*-*.tgz
187166
combined-checksums.*
188-
prerelease: ${{ steps.version.outputs.is_rc }}
167+
prerelease: ${{ steps.version.outputs.is_rc }}

0 commit comments

Comments
 (0)