-
Notifications
You must be signed in to change notification settings - Fork 62
161 lines (139 loc) · 5.37 KB
/
release.yml
File metadata and controls
161 lines (139 loc) · 5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v1.0.0 or rc-1)'
required: true
type: string
jobs:
get-version:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: version
run: |
BASE_VERSION=$(node -p "require('./package.json').version")
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT
build:
needs: [get-version]
timeout-minutes: 30
permissions:
id-token: write
contents: read
strategy:
matrix:
arch: [x86_64, aarch64]
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install build dependencies
run: |
apt-get update
apt-get install -y cmake make g++ autotools-dev automake libtool
- name: Build natively for ${{ matrix.arch }}
run: |
echo "Building for architecture: ${{ matrix.arch }}"
# Build native dependencies and JavaScript
BUILD=1 npm install
npm run build
# Verify required files were created
if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then
echo "Error: Required files not found in dist directory"
exit 1
fi
# Copy architecture-specific package.json to dist
node -e "
const pkg = require('./package.json');
pkg.name = 'aws-lambda-ric-${{ matrix.arch }}';
require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2));
"
# Create tarball with only required files
tar -czf aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz \
-C dist package.json index.mjs UserFunction.js rapid-client.node
- name: Generate checksums
run: |
PACKAGE_FILE="aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz"
sha256sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha256
sha512sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha512
echo "Package: $PACKAGE_FILE (${{ matrix.arch }}) with version: ${{ needs.get-version.outputs.version }}" > checksums-${{ matrix.arch }}.txt
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}
path: |
aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz
checksums-*
retention-days: 30
publish:
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
needs: [get-version, build]
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Download x86_64 artifacts
uses: actions/download-artifact@v4
with:
name: package-x86_64-${{ needs.get-version.outputs.version }}
path: ./artifacts/x86_64
- name: Download aarch64 artifacts
uses: actions/download-artifact@v4
with:
name: package-aarch64-${{ needs.get-version.outputs.version }}
path: ./artifacts/aarch64
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Setup NPM authentication
run: |
NPM_TOKEN=$(aws secretsmanager get-secret-value --secret-id ${{ secrets.NPM_SECRET_NAME }} --query SecretString --output text)
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
chmod 0600 .npmrc
- name: Create and push tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ inputs.tag }}
git push origin ${{ inputs.tag }}
- name: Determine version and publish packages
id: version
run: |
if [[ "${{ inputs.tag }}" == rc-* ]]; then
RC_NUMBER=${GITHUB_REF#refs/tags/rc-}
PACKAGE_VERSION="${{ needs.get-version.outputs.version }}-rc.${RC_NUMBER}"
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "is_rc=true" >> $GITHUB_OUTPUT
TAG_FLAG="--tag rc"
else
echo "package_version=${{ needs.get-version.outputs.version }}" >> $GITHUB_OUTPUT
TAG_FLAG=""
fi
# Build and publish full package to npm
BUILD=1 npm install
npm run build
npm publish $TAG_FLAG --access=public
- name: Combine checksums
run: |
cat ./artifacts/*/checksums-*.txt > combined-checksums.txt
cat ./artifacts/*/checksums-*.sha256 > combined-checksums.sha256
cat ./artifacts/*/checksums-*.sha512 > combined-checksums.sha512
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
files: |
./artifacts/*/aws-lambda-ric-*-*.tgz
combined-checksums.*
prerelease: ${{ steps.version.outputs.is_rc }}