Build releases #578
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: 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: Init centos rootfs | |
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/sbwml/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+") | |
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+") | |
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 }}-${{ matrix.tag }} | |
allowUpdates: true | |
tag: v${{ env.VERSION }} | |
commit: master | |
replacesArtifacts: true | |
token: ${{ secrets.workflow_token }} | |
artifacts: out/* |