-
Notifications
You must be signed in to change notification settings - Fork 62
209 lines (184 loc) · 6.26 KB
/
build-and-release.yml
File metadata and controls
209 lines (184 loc) · 6.26 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Build and Release
on:
push:
branches: [ fabisev/artifact-publishing ]
tags: [ 'v*', 'rc-*' ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
test_mode:
description: 'Test mode (release, rc, or none)'
required: true
default: 'none'
type: choice
options:
- none
- release
- rc
jobs:
# Commenting out lint job as it's failing
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '20'
# cache: 'npm'
# - name: Install and lint
# run: |
# npm ci
# npm run lint
# npm run format
build:
runs-on: ubuntu-latest
# Removed dependency on lint job
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Get version
id: version
run: |
BASE_VERSION=$(node -p "require('./package.json').version")
VERSION="${BASE_VERSION}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Cache native dependencies
uses: actions/cache@v4
with:
path: |
deps/
build/
key: native-deps-${{ runner.os }}-${{ hashFiles('deps/versions', 'binding.gyp') }}
- name: Install and build
run: |
npm ci
npm run build
npm pack
- name: Generate checksums and signatures
run: |
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
sha256sum $PACKAGE_FILE > checksums.sha256
sha512sum $PACKAGE_FILE > checksums.sha512
cat checksums.sha256 checksums.sha512 > checksums.txt
echo "Package: $PACKAGE_FILE with version prefix: ${{ steps.version.outputs.version }}" >> checksums.txt
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: package-${{ steps.version.outputs.version }}
path: |
aws-lambda-ric-*.tgz
checksums.*
retention-days: 30
test:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- name: Run unit tests - Node ${{ matrix.node-version }}
run: |
docker build -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x -t unit/nodejs.${{ matrix.node-version }}x .
docker run --rm unit/nodejs.${{ matrix.node-version }}x
publish:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [build, test]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: package-${{ needs.build.outputs.version }}
- name: Verify checksums
run: |
sha256sum -c checksums.sha256
sha512sum -c checksums.sha512
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Handle release candidate version if needed
- name: Determine version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/rc-* ]]; then
RC_NUMBER=${GITHUB_REF#refs/tags/rc-}
PACKAGE_VERSION="${{ needs.build.outputs.version }}-rc.${RC_NUMBER}"
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "is_rc=true" >> $GITHUB_OUTPUT
# Update package.json version to include RC suffix
npm version $PACKAGE_VERSION --no-git-tag-version
else
echo "package_version=${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT
echo "is_rc=false" >> $GITHUB_OUTPUT
fi
# Commented out npm publishing until token is available
# - name: Publish to npm
# run: |
# if [[ "${{ steps.version.outputs.is_rc }}" == "true" ]]; then
# npm publish aws-lambda-ric-*.tgz --tag rc
# else
# npm publish aws-lambda-ric-*.tgz
# fi
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
aws-lambda-ric-*.tgz
checksums.sha256
checksums.sha512
checksums.txt
prerelease: ${{ steps.version.outputs.is_rc }}
name: ${{ steps.version.outputs.is_rc == 'true' && format('Release Candidate {0}', steps.version.outputs.package_version) || '' }}
generate_release_notes: true
test-publish:
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.test_mode != 'none') || github.ref == 'refs/heads/fabisev/artifact-publishing'
runs-on: ubuntu-latest
needs: [build, test]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: package-${{ needs.build.outputs.version }}
- name: Verify checksums
run: |
sha256sum -c checksums.sha256
sha512sum -c checksums.sha512
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Test Release Publishing
if: github.event.inputs.test_mode == 'release' || github.ref == 'refs/heads/fabisev/artifact-publishing'
run: |
echo "=== TESTING RELEASE PUBLISHING (DRY RUN) ==="
echo "Would create a GitHub release with the following files:"
ls -la aws-lambda-ric-*.tgz checksums.*
echo "\nRelease would include version: ${{ needs.build.outputs.version }}"
- name: Test RC Publishing
if: github.event.inputs.test_mode == 'rc'
run: |
echo "=== TESTING RC PUBLISHING (DRY RUN) ==="
# Simulate RC version
RC_NUMBER="1"
PACKAGE_VERSION="${{ needs.build.outputs.version }}-rc.${RC_NUMBER}"
echo "Would create a GitHub pre-release with the following files:"
ls -la aws-lambda-ric-*.tgz checksums.*
echo "\nRelease would include version: ${PACKAGE_VERSION}"
# Update version for display purposes
npm version ${PACKAGE_VERSION} --no-git-tag-version