Skip to content

Commit b577cda

Browse files
Add fips build workflow
1 parent b9b6b32 commit b577cda

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build Node with FIPS-enabled OpenSSL
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
BUILD_REF:
7+
description: 'Git ref to build Node.js from'
8+
required: true
9+
default: 'v22.21.1'
10+
type: string
11+
DOCKER_FILE:
12+
description: 'Dockerfile to use for building Node.js'
13+
required: true
14+
default: 'Dockerfile.Node22fips'
15+
type: string
16+
17+
jobs:
18+
build-node:
19+
name: Build ${{ matrix.platform }}-${{ matrix.arch }} with FIPS OpenSSL
20+
strategy:
21+
matrix:
22+
include:
23+
- platform: linux
24+
arch: x64
25+
runs_on: ubuntu-22.04
26+
- platform: linux
27+
arch: arm64
28+
runs_on: ubuntu-22.04-arm
29+
runs-on: ${{ matrix.runs_on }}
30+
31+
steps:
32+
- name: Checkout Node fork
33+
uses: actions/checkout@v3
34+
with:
35+
repository: Asana/node
36+
path: node
37+
ref: ${{ inputs.BUILD_REF }}
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract Node Version
41+
id: extract-node-version
42+
run: |
43+
NODE_MAJOR_VERSION=$(grep '#define NODE_MAJOR_VERSION' node/src/node_version.h | awk '{print $3}')
44+
NODE_MINOR_VERSION=$(grep '#define NODE_MINOR_VERSION' node/src/node_version.h | awk '{print $3}')
45+
NODE_PATCH_VERSION=$(grep '#define NODE_PATCH_VERSION' node/src/node_version.h | awk '{print $3}')
46+
NODE_VERSION="v${NODE_MAJOR_VERSION}.${NODE_MINOR_VERSION}.${NODE_PATCH_VERSION}"
47+
echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV
48+
49+
- name: Set build metadata
50+
id: meta
51+
working-directory: node
52+
run: |
53+
TIMESTAMP=$(date -u +%Y-%m-%dT%H-%M)
54+
SHORT_SHA=$(git rev-parse --short HEAD)
55+
echo "BUILD_ID=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_ENV
56+
echo "build_id=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT
57+
58+
- name: Execute the Dockerfile
59+
working-directory: node
60+
run: |
61+
docker build -t node22_fips_build -f ./${{ inputs.DOCKER_FILE }} .
62+
63+
- name: Extract resources
64+
run: |
65+
docker create --name temp_node_extract node22_fips_build
66+
docker cp temp_node_extract:/usr/src/node/node-install $GITHUB_WORKSPACE/node-install
67+
docker rm temp_node_extract
68+
69+
- name: Archive Node
70+
run: |
71+
mkdir -p artifacts
72+
FILENAME=node-${NODE_VERSION}-fips-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}.tar.xz
73+
FILENAME_LATEST=node-${NODE_VERSION}-fips-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz
74+
tar -C node-install -cJf artifacts/$FILENAME .
75+
cp artifacts/$FILENAME artifacts/$FILENAME_LATEST
76+
echo "NODE_ARCHIVE=$FILENAME" >> $GITHUB_ENV
77+
echo "NODE_ARCHIVE_LATEST=$FILENAME_LATEST" >> $GITHUB_ENV
78+
79+
- name: Upload Node archive
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: node-${{ env.NODE_VERSION }}-fips-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}
83+
path: artifacts/${{ env.NODE_ARCHIVE }}
84+
85+
- name: Upload Node archive latest
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: node-${{ env.NODE_VERSION }}-fips-${{ matrix.platform }}-${{ matrix.arch }}-LATEST
89+
path: artifacts/${{ env.NODE_ARCHIVE_LATEST }}
90+
91+
- name: Upload Node archive to release
92+
uses: softprops/action-gh-release@v1
93+
with:
94+
name: node-${{ env.NODE_VERSION }}-fips-LATEST
95+
tag_name: node-${{ env.NODE_VERSION }}-fips-release
96+
files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }}
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)