1+ name : Build and Release
2+
3+ on :
4+ push :
5+ branches : [ fabisev/artifact-publishing ]
6+ tags : [ 'v*' ]
7+ pull_request :
8+ branches : [ main ]
9+
10+ jobs :
11+ # lint:
12+ # runs-on: ubuntu-latest
13+ # steps:
14+ # - uses: actions/checkout@v4
15+ # - name: Setup Node.js
16+ # uses: actions/setup-node@v4
17+ # with:
18+ # node-version: '20'
19+ # cache: 'npm'
20+ # - name: Install and lint
21+ # run: |
22+ # npm ci
23+ # npm run lint
24+ # npm run format
25+
26+ build :
27+ runs-on : ubuntu-latest
28+ outputs :
29+ version : ${{ steps.version.outputs.version }}
30+ steps :
31+ - uses : actions/checkout@v4
32+
33+ - name : Setup Node.js
34+ uses : actions/setup-node@v4
35+ with :
36+ node-version : ' 20'
37+ cache : ' npm'
38+
39+ - name : Get version
40+ id : version
41+ run : |
42+ BASE_VERSION=$(node -p "require('./package.json').version")
43+ VERSION="${BASE_VERSION}"
44+ echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
46+ - name : Cache native dependencies
47+ uses : actions/cache@v4
48+ with :
49+ path : |
50+ deps/
51+ build/
52+ key : native-deps-${{ runner.os }}-${{ hashFiles('deps/versions', 'binding.gyp') }}
53+
54+ - name : Install and build
55+ run : |
56+ npm ci
57+ npm run build
58+ npm pack
59+
60+ - name : Generate checksums and signatures
61+ run : |
62+ PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
63+ sha256sum $PACKAGE_FILE > checksums.sha256
64+ sha512sum $PACKAGE_FILE > checksums.sha512
65+ cat checksums.sha256 checksums.sha512 > checksums.txt
66+ echo "Package: $PACKAGE_FILE with version prefix: ${{ steps.version.outputs.version }}" >> checksums.txt
67+
68+ - name : Upload artifacts
69+ uses : actions/upload-artifact@v4
70+ with :
71+ name : package-${{ steps.version.outputs.version }}
72+ path : |
73+ aws-lambda-ric-*.tgz
74+ checksums.*
75+ retention-days : 30
76+
77+ test :
78+ runs-on : ubuntu-latest
79+ needs : [build] # don't forget to add lint later
80+ strategy :
81+ matrix :
82+ node-version : [18, 20, 22]
83+ steps :
84+ - uses : actions/checkout@v4
85+
86+ - name : Run unit tests - Node ${{ matrix.node-version }}
87+ run : |
88+ docker build -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x -t unit/nodejs.${{ matrix.node-version }}x .
89+ docker run --rm unit/nodejs.${{ matrix.node-version }}x
90+
91+
92+
93+ publish :
94+ if : startsWith(github.ref, 'refs/tags/v')
95+ runs-on : ubuntu-latest
96+ needs : [build, test]
97+ permissions :
98+ contents : write
99+ steps :
100+ - uses : actions/checkout@v4
101+
102+ - name : Download artifacts
103+ uses : actions/download-artifact@v4
104+ with :
105+ name : package-${{ needs.build.outputs.version }}
106+
107+ - name : Verify checksums
108+ run : |
109+ sha256sum -c checksums.sha256
110+ sha512sum -c checksums.sha512
111+
112+ - name : Setup Node.js
113+ uses : actions/setup-node@v4
114+ with :
115+ node-version : ' 20'
116+ registry-url : ' https://registry.npmjs.org'
117+
118+ # - name: Publish to npm
119+ # run: npm publish aws-lambda-ric-*.tgz
120+ # env:
121+ # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
122+
123+ - name : Create GitHub Release
124+ uses : softprops/action-gh-release@v2
125+ with :
126+ files : |
127+ aws-lambda-ric-*.tgz
128+ checksums.sha256
129+ checksums.sha512
130+ checksums.txt
131+ generate_release_notes : true
0 commit comments