Skip to content

Node.js custom build job #20

Node.js custom build job

Node.js custom build job #20

Workflow file for this run

name: Node.js custom build job
on:
workflow_dispatch:
inputs:
version:
description: 'Node.js version'
required: true
default: 'v22.9.0'
use_cache:
description: 'Use cache'
type: boolean
required: true
default: false
latest_version:
description: 'Latest'
type: boolean
required: true
default: false
jobs:
build-custom:
runs-on: ubuntu-latest
env:
version: ${{ github.event.inputs.version }}
use_cache: ${{ github.event.inputs.use_cache }}
latest_version: ${{ github.event.inputs.latest_version }}
strategy:
matrix:
name: ['node']
binaries: ['glibc', 'musl']
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
run: |
case ${{ matrix.binaries }} in
glibc)
if [ "${{ env.major_version }}" -gt "20" ]; then
# https://github.com/nodejs/node/pull/52888
exit 0
fi
gh release view ${{ env.version }} -R ${{ github.repository }} | grep node-${{ env.version }}-linux-loong64.tar.xz >/dev/null 2>&1 || echo "create=1" >> $GITHUB_ENV
;;
musl)
gh release view ${{ env.version }} -R ${{ github.repository }} | grep node-${{ env.version }}-linux-loong64-musl.tar.xz >/dev/null 2>&1 || echo "create=1" >> $GITHUB_ENV
;;
esac
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
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@v4
if: env.create == '1'
with:
repository: loong64/unofficial-builds
path: unofficial-builds
- uses: docker/setup-buildx-action@v3
if: env.create == '1'
- name: Setup QEMU
if: env.create == '1'
run: |
docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes
- name: Cache node.js
if: env.create == '1'
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/workdir/.ccache
key: ${{ matrix.name }}-${{ matrix.binaries }}-v${{ env.major_version }}-${{ github.sha }}
restore-keys: |
${{ matrix.name }}-${{ matrix.binaries }}-v${{ env.major_version }}-
- name: Set Cache
if: env.use_cache == 'true'
run: |
mkdir -p ${{ github.workspace }}/workdir/staging
sudo chmod -R 777 ${{ github.workspace }}/workdir/staging
sudo chown -R 1000:docker ${{ github.workspace }}/workdir/staging
case ${{ matrix.binaries }} in
glibc)
echo "Pass ..."
;;
musl)
wget https://www.wuxiaobai.win/download/node-cache-${{ env.version }}-linux-loong64-musl.tar.gz
tar -pxf node-cache-${{ env.version }}-linux-loong64-musl.tar.gz -C ${{ github.workspace }}/workdir
;;
esac
- name: Build node.js
if: env.create == '1'
run: |
case ${{ matrix.binaries }} in
glibc)
./bin/local_build.sh -r loong64 -v ${{ env.version }} -w ${{ github.workspace }}/workdir
cd ${{ github.workspace }}/workdir/staging/release/${{ env.version }}
sha256sum node-${{ env.version }}-linux-loong64.tar.gz > node-${{ env.version }}-linux-loong64.tar.gz.sha256
sha256sum node-${{ env.version }}-linux-loong64.tar.xz > node-${{ env.version }}-linux-loong64.tar.xz.sha256
;;
musl)
./bin/local_build.sh -r musl -v ${{ env.version }} -w ${{ github.workspace }}/workdir
cd ${{ github.workspace }}/workdir/staging/release/${{ env.version }}
sha256sum node-${{ env.version }}-linux-loong64-musl.tar.gz > node-${{ env.version }}-linux-loong64-musl.tar.gz.sha256
sha256sum node-${{ env.version }}-linux-loong64-musl.tar.xz > node-${{ env.version }}-linux-loong64-musl.tar.xz.sha256
;;
esac
working-directory: unofficial-builds
- 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
gh release upload ${{ env.version }} -R ${{ github.repository }} ${{ github.workspace }}/workdir/staging/src/${{ env.version }}/* || true
gh release upload ${{ env.version }} -R ${{ github.repository }} ${{ github.workspace }}/workdir/staging/release/${{ env.version }}/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}