Node.js daily build job #119
This file contains 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 daily build job | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 0 * * * | |
jobs: | |
build-daily: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
name: ['node'] | |
binaries: ['glibc', 'musl'] | |
version: ['18', '20', '22', '23' ] | |
latest_version: ['23'] | |
steps: | |
- name: Check version | |
run: | | |
version=$(curl -s https://nodejs.org/download/release/index.json | jq -r '.[] | .version' | grep -E '^v'"${{ matrix.version }}" | head -n 1) | |
if [ -z "${version}" ]; then | |
echo "Node.js version not found" | |
exit 1 | |
fi | |
echo "version=${version}" >> $GITHUB_ENV | |
echo "Node.js current version: ${version}" | |
major_version=$(echo ${{ matrix.version }} | sed 's/^v//') | |
echo "major_version=${major_version}" >> $GITHUB_ENV | |
- name: Check release | |
run: | | |
case ${{ matrix.binaries }} in | |
glibc) | |
if [ "${{ matrix.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 permissions | |
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: | | |
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="" | |
majorVersion=$(echo ${{ env.version }} | cut -d . -f 1 | tr --delete v) | |
if [ "${majorVersion}" != "${{ matrix.latest_version }}" ]; 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 }} |