Skip to content

Build releases

Build releases #133

Workflow file for this run

name: Build releases
on:
workflow_dispatch:
schedule:
- cron: 0 23 * * *
jobs:
build:
name: Build ${{ matrix.tag }} Version
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
tag:
- lts
- current
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setting up the environment
run: |
wget -q https://github.com/sbwml/kernel-latest-centos/releases/download/rootfs/rootfs.tar.xz
tar xf rootfs.tar.xz && rm -f rootfs.tar.xz
echo "rootfs=$(pwd)/rootfs" >> "$GITHUB_ENV"
sudo mount -o bind /dev rootfs/dev
sudo mount -t proc /proc rootfs/proc
sudo mount -t sysfs /sys rootfs/sys
- name: Check Node Version
run: |
TAGS=$(curl -sk https://api.github.com/repos/Lugdunumn/node-latest-centos/tags | grep "name")
if [[ ${{ matrix.tag }} == "lts" ]]; then
LATEST_VERSION=$(curl -s "https://api.github.com/repos/nodejs/node/releases" | grep 'Version.*LTS' | sed '/body/d' | head -1 | grep -oP "(?<=Version )\d+\.\d+\.\d+")
echo "PRE_RELEASE=false" >> "$GITHUB_ENV"
else
LATEST_VERSION=$(curl -s "https://api.github.com/repos/nodejs/node/releases" | grep 'Version.*Current'| sed '/body/d' | head -1 | grep -oP "(?<=Version )\d+\.\d+\.\d+")
echo "PRE_RELEASE=true" >> "$GITHUB_ENV"
fi
if [[ "$TAGS" == *"$LATEST_VERSION"* ]]; then
echo -e " \n\e[1;32mnode-v$LATEST_VERSION is already the latest version.\e[0m\n"
exit 0
else
echo "VERSION=$LATEST_VERSION" >> "$GITHUB_ENV"
echo "next=true" >> "$GITHUB_ENV"
fi
- name: Build Node.js
if: env.next == 'true'
run: |
sudo cp -a build.sh ${{ env.rootfs }}
sudo cp -a repo/devtoolset-12.repo ${{ env.rootfs }}/etc/yum.repos.d
sudo chroot ${{ env.rootfs }} /bin/bash /build.sh ${{ env.VERSION }}
mkdir out
sudo cp -a ${{ env.rootfs }}/node-v*.tar.* out
sudo cp -a ${{ env.rootfs }}/sha256sum.txt out
- name: Upload Artifacts
if: env.next == 'true'
uses: actions/upload-artifact@v4
with:
name: node-v${{ env.VERSION }}
path: out/*
- name: Create release
if: env.next == 'true'
uses: ncipollo/[email protected]
with:
name: node-v${{ env.VERSION }}
allowUpdates: true
tag: v${{ env.VERSION }}
commit: master
replacesArtifacts: true
prerelease: ${{ env.PRE_RELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: out/*