|
| 1 | +name: Build Node with options around OpenSSL dynamic linking and FIPS |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + enableFips: |
| 7 | + description: 'Whether OpenSSL should be FIPS-enabled' |
| 8 | + default: true |
| 9 | + type: boolean |
| 10 | + dynamicLink: |
| 11 | + description: 'If OpenSSL should be dynamically linked with node (rather than statically linked)' |
| 12 | + default: false |
| 13 | + type: boolean |
| 14 | + sharedOpenSSLIncludes: |
| 15 | + description: 'dir containing header files for OpenSSL' |
| 16 | + default: '' |
| 17 | + type: string |
| 18 | + sharedOpenSSLLibname: |
| 19 | + description: 'libname for dynamically linking to OpenSSL' |
| 20 | + default: '' |
| 21 | + type: string |
| 22 | + sharedOpenSSLLibpath: |
| 23 | + description: 'dir for searching for shared OpenSSL dlls' |
| 24 | + default: '' |
| 25 | + type: string |
| 26 | + |
| 27 | +jobs: |
| 28 | + build-node: |
| 29 | + name: Build ${{ matrix.platform }}-${{ matrix.arch }} with statically-linked FIPS OpenSSL |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - platform: linux |
| 34 | + arch: x64 |
| 35 | + runs_on: ubuntu-22.04 |
| 36 | + - platform: linux |
| 37 | + arch: arm64 |
| 38 | + runs_on: ubuntu-22.04-arm |
| 39 | + runs-on: ${{ matrix.runs_on }} |
| 40 | + |
| 41 | + env: |
| 42 | + S3_BUCKET: your-bucket-name |
| 43 | + AWS_REGION: us-east-1 |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout Node fork |
| 47 | + uses: actions/checkout@v3 |
| 48 | + with: |
| 49 | + repository: Asana/node |
| 50 | + path: node |
| 51 | + ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.ref_name }} |
| 52 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Extract Node Version |
| 55 | + id: extract-node-version |
| 56 | + run: | |
| 57 | + NODE_MAJOR_VERSION=$(grep '#define NODE_MAJOR_VERSION' node/src/node_version.h | awk '{print $3}') |
| 58 | + NODE_MINOR_VERSION=$(grep '#define NODE_MINOR_VERSION' node/src/node_version.h | awk '{print $3}') |
| 59 | + NODE_PATCH_VERSION=$(grep '#define NODE_PATCH_VERSION' node/src/node_version.h | awk '{print $3}') |
| 60 | + NODE_VERSION="v${NODE_MAJOR_VERSION}.${NODE_MINOR_VERSION}.${NODE_PATCH_VERSION}" |
| 61 | + echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Set build metadata |
| 64 | + id: meta |
| 65 | + working-directory: node |
| 66 | + run: | |
| 67 | + TIMESTAMP=$(date -u +%Y-%m-%dT%H-%M) |
| 68 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 69 | + echo "BUILD_ID=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_ENV |
| 70 | + echo "build_id=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + - name: Install dependencies (Linux) |
| 73 | + if: matrix.platform == 'linux' |
| 74 | + run: | |
| 75 | + sudo apt-get update |
| 76 | + sudo apt-get install -y python3 g++ make curl tar xz-utils |
| 77 | + |
| 78 | + - name: Configure OpenSSL for fips |
| 79 | + id: openssl-is-fips |
| 80 | + if: inputs.enableFips |
| 81 | + run: | |
| 82 | + ./configure --openssl-is-fips |
| 83 | +
|
| 84 | + - name: Dynamically link OpenSSL in Node.js |
| 85 | + id: openssl-dynamic-link |
| 86 | + if: inputs.dynamicLink |
| 87 | + run: | |
| 88 | + ./configure --shared-openssl |
| 89 | +
|
| 90 | + - name: Define headers for OpenSSL |
| 91 | + id: openssl-dynamic-link-headers |
| 92 | + if: ${{ !empty(inputs.sharedOpenSSLIncludes) }} |
| 93 | + run: | |
| 94 | + ./configure --shared-openssl-includes ${{inputs.sharedOpenSSLIncludes}} |
| 95 | +
|
| 96 | + - name: alternative libname for openssl |
| 97 | + id: openssl-dynamic-link-libname |
| 98 | + if: ${{ !empty(inputs.sharedOpenSSLLibname) }} |
| 99 | + run: | |
| 100 | + ./configure --shared-openssl-libname ${{inputs.sharedOpenSSLLibname}} |
| 101 | +
|
| 102 | + - name: Define headers for OpenSSL |
| 103 | + id: openssl-dynamic-link-libpath |
| 104 | + if: ${{ !empty(inputs.sharedOpenSSLLibpath) }} |
| 105 | + run: | |
| 106 | + ./configure --shared-openssl-includes ${{inputs.sharedOpenSSLLibpath}} |
| 107 | +
|
| 108 | +
|
| 109 | + - name: Build Node (linux) |
| 110 | + working-directory: node |
| 111 | + if: matrix.platform == 'linux' |
| 112 | + run: | |
| 113 | + ./configure --experimental-enable-pointer-compression |
| 114 | + make -j4 install DESTDIR=$GITHUB_WORKSPACE/node-install |
| 115 | +
|
| 116 | + - name: Build Node (darwin) |
| 117 | + working-directory: node |
| 118 | + if: matrix.platform == 'darwin' |
| 119 | + run: | |
| 120 | + ./configure --experimental-enable-pointer-compression --without-snapshot |
| 121 | + make -j2 install DESTDIR=$GITHUB_WORKSPACE/node-install |
| 122 | +
|
| 123 | + - name: Archive Node |
| 124 | + run: | |
| 125 | + mkdir -p artifacts |
| 126 | + FILENAME=node-${NODE_VERSION}-fips-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}.tar.xz |
| 127 | + FILENAME_LATEST=node-${NODE_VERSION}-fips-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz |
| 128 | + tar -C node-install -cJf artifacts/$FILENAME . |
| 129 | + cp artifacts/$FILENAME artifacts/$FILENAME_LATEST |
| 130 | + echo "NODE_ARCHIVE=$FILENAME" >> $GITHUB_ENV |
| 131 | + echo "NODE_ARCHIVE_LATEST=$FILENAME_LATEST" >> $GITHUB_ENV |
| 132 | +
|
| 133 | + - name: Upload Node archive |
| 134 | + uses: actions/upload-artifact@v4 |
| 135 | + with: |
| 136 | + name: node-${{ env.NODE_VERSION }}-fips-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }} |
| 137 | + path: artifacts/${{ env.NODE_ARCHIVE }} |
| 138 | + |
| 139 | + - name: Upload Node archive latest |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: node-${{ env.NODE_VERSION }}-fips-${{ matrix.platform }}-${{ matrix.arch }}-LATEST |
| 143 | + path: artifacts/${{ env.NODE_ARCHIVE_LATEST }} |
| 144 | + |
| 145 | + - name: Upload Node archive to release |
| 146 | + uses: softprops/action-gh-release@v1 |
| 147 | + with: |
| 148 | + name: node-${{ env.NODE_VERSION }}-fips-static-LATEST |
| 149 | + tag_name: node-${{ env.NODE_VERSION }}-fips-static-release |
| 150 | + files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }} |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments