Skip to content

Node.js custom build job #81

Node.js custom build job

Node.js custom build job #81

Workflow file for this run

name: Node.js custom build job
on:
workflow_dispatch:
inputs:
version:
description: 'Node.js version'
required: true
default: 'v25.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:
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@v5
if: env.create == '1'
with:
path: main
- name: Create tag
if: env.create == '1'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ env.version }} || true
git push origin ${{ env.version }} --force
working-directory: main
- uses: actions/checkout@v5
if: env.create == '1'
with:
repository: loong64/node-unofficial-builds
path: unofficial-builds
- uses: docker/setup-qemu-action@v3
if: env.create == '1'
- uses: docker/setup-buildx-action@v3
if: env.create == '1'
- name: Restore Cache
if: env.create == '1'
id: cache-restore
uses: actions/cache/restore@v4
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
./bin/local_build.sh -r loong64-${{ matrix.binaries }} -v ${{ env.version }} -w ${{ github.workspace }}/workdir
mkdir -p ${{ github.workspace }}/dist
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@v4
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@v4
with:
name: node-${{ env.version }}-linux-loong64-${{ matrix.binaries }}
path: ${{ github.workspace }}/dist/*
- name: Create release
if: env.create == '1'
run: |
latestFlag=""
if [ "${{ env.latest_version }}" != "true" ]; then
latestFlag="--latest=false"
fi
gh release create ${{ env.version }} -R ${{ github.repository }} --title ${{ env.version }} --notes "**Full Changelog**: [${{ env.version }}](https://github.com/nodejs/node/releases/tag/${{ env.version }})" ${latestFlag} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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@v5
- 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@v4
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 --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 upload ${{ env.version }} -R ${{ github.repository }} dist/* --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}