Node.js custom build job #135
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Node.js custom build job | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Node.js version' | |
| required: true | |
| default: 'v26.0.0' | |
| latest_version: | |
| description: 'Latest' | |
| type: boolean | |
| required: true | |
| default: false | |
| jobs: | |
| build-custom: | |
| name: Build Node.js ${{ github.event.inputs.version }} ${{ matrix.binaries }} | |
| runs-on: ubuntu-latest | |
| env: | |
| version: ${{ github.event.inputs.version }} | |
| latest_version: ${{ github.event.inputs.latest_version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| name: ['node'] | |
| binaries: ['gnu', 'musl'] | |
| outputs: | |
| create: ${{ steps.check_release.outputs.create }} | |
| steps: | |
| - name: Check version | |
| run: | | |
| echo "Node.js current version: ${version}, latest: ${latest_version}" | |
| major_version=$(echo $version | sed 's/^v//' | cut -d '.' -f 1) | |
| echo "major_version=${major_version}" >> $GITHUB_ENV | |
| - name: Check release | |
| id: check_release | |
| run: | | |
| gh release view ${{ env.version }} -R ${{ github.repository }} | grep SHASUMS256.txt.asc >/dev/null 2>&1 || create=1 | |
| echo "create=${create:-0}" >> $GITHUB_ENV | |
| echo "create=${create:-0}" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/checkout@v6 | |
| if: env.create == '1' | |
| with: | |
| path: main | |
| - uses: actions/checkout@v6 | |
| if: env.create == '1' | |
| with: | |
| repository: loong64/node-unofficial-builds | |
| path: unofficial-builds | |
| - uses: docker/setup-qemu-action@v4 | |
| if: env.create == '1' | |
| - uses: docker/setup-buildx-action@v4 | |
| if: env.create == '1' | |
| - name: Restore Cache | |
| if: env.create == '1' | |
| id: cache-restore | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: ${{ github.workspace }}/workdir/.ccache | |
| key: ${{ matrix.name }}-${{ matrix.binaries }}-v${{ env.major_version }}- | |
| - name: Set Cache | |
| if: env.create == '1' | |
| run: | | |
| mkdir -p ${{ github.workspace }}/workdir/staging | |
| sudo chmod -R 777 ${{ github.workspace }}/workdir/staging | |
| sudo chown -R 1000:docker ${{ github.workspace }}/workdir/staging | |
| - name: Build node.js | |
| if: env.create == '1' | |
| run: | | |
| # if [ "${{ env.major_version }}" -ge "24" ]; then | |
| # sed -i 's@stable@mainline@g' recipes/loong64-${{ matrix.binaries }}/Dockerfile | |
| # fi | |
| mkdir -p ${{ github.workspace }}/dist | |
| ./bin/local_build.sh -r loong64-${{ matrix.binaries }} -v ${{ env.version }} -w ${{ github.workspace }}/workdir | |
| cp -f ${{ github.workspace }}/workdir/staging/release/${{ env.version }}/* ${{ github.workspace }}/dist/ | |
| if [ ${{ matrix.binaries }} = "gnu" ]; then | |
| cp -f ${{ github.workspace }}/workdir/staging/src/${{ env.version }}/* ${{ github.workspace }}/dist/ | |
| fi | |
| working-directory: unofficial-builds | |
| - name: Save Cache | |
| if: always() && env.create == '1' | |
| id: cache-save | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: ${{ github.workspace }}/workdir/.ccache | |
| key: ${{ matrix.name }}-${{ matrix.binaries }}-v${{ env.major_version }}-${{ github.run_id }} | |
| - name: Upload Artifacts | |
| if: env.create == '1' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: node-${{ env.version }}-linux-loong64-${{ matrix.binaries }} | |
| path: ${{ github.workspace }}/dist/* | |
| release: | |
| if: needs.build-custom.outputs.create == '1' | |
| needs: build-custom | |
| runs-on: ubuntu-latest | |
| env: | |
| version: ${{ github.event.inputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Import GPG key | |
| id: import_gpg | |
| uses: crazy-max/ghaction-import-gpg@v6 | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.PASSPHRASE }} | |
| - name: Prepare scripts | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y reprepro gnupg-agent | |
| mkdir -p dist | |
| echo > ~/.gnupg/gpg-agent.conf <<EOF | |
| max-cache-ttl 60480000 | |
| default-cache-ttl 60480000 | |
| allow-preset-passphrase | |
| EOF | |
| gpg-connect-agent reloadagent /bye | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: node-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Sign Release | |
| run: | | |
| KEYGRIP=$(gpg -K --with-keygrip | grep Keygrip | head -1 | awk '{print $3}') | |
| /usr/lib/gnupg2/gpg-preset-passphrase --preset "$KEYGRIP" <<< "${{ secrets.PASSPHRASE }}" | |
| cd dist | |
| rm -f SHASUMS256.txt SHASUMS256.txt.asc | |
| sha256sum node-* > SHASUMS256.txt | |
| gpg --output SHASUMS256.txt.asc --clearsign SHASUMS256.txt | |
| gpg --output SHASUMS256.txt.sig --detach-sig SHASUMS256.txt | |
| ls -lFh node-* SHASUMS256.txt* | |
| for f in node-*; do | |
| sha256sum "$f" > "$f".sha256 | |
| done | |
| - name: Upload Release | |
| run: | | |
| gh release create ${{ env.version }} -R ${{ github.repository }} --generate-notes dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |