Skip to content

Package against beta-0.12.0 #94

Package against beta-0.12.0

Package against beta-0.12.0 #94

name: "Stage 1 - Run prebuild's and Create GitHub and NPM release"
run-name: Package against ${{ github.ref_name }}
# Create branch for release
# update package.json for package version
on:
workflow_dispatch:
inputs:
Beta:
description: "Beta Release"
required: true
default: true
type: boolean
env:
# Order reversed so newer versions are built first - Add new versions to the front (fail fast)
# electronBuildTargets version 28 has an issue
oldNodeBuildTargets: -t 17.0.1
currentNodeBuildTargets: -t 23.0.0 -t 22.0.0 -t 21.0.0 -t 20.0.0 -t 19.0.0 -t 18.0.0
oldElectronBuildTargets: -t 19.0.0 -t 18.0.0 -t 17.0.0
electronBuildTargets: -t 29.0.0 -t 27.0.0 -t 26.0.0 -t 25.0.0 -t 24.0.0 -t 23.0.0 -t 22.0.0 -t 21.0.0 -t 20.0.0
winIA32nodeBuildTargets: -t 17.0.1
winIA32electronBuildTargets: -t 29.0.0 -t 27.0.0 -t 26.0.0 -t 25.0.0 -t 24.0.0 -t 23.0.0 -t 22.0.0 -t 21.0.0 -t 20.0.0
ReleasePrebuildCount: 192
ReleasePrebuildifyCount: 49
jobs:
prebuild:
name: ${{ matrix.name }} - Prebuild NPM and GitHub Release artifacts
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name:
[
darwin-x64,
darwin-arm64,
linux-arm,
linux-arm64,
linux-arm64-older,
linux-ia32,
linux-ia32-older,
linux-x64,
linux-x64-older,
linuxmusl-arm,
linuxmusl-arm64,
linuxmusl-x64,
win32-ia32,
win32-x64,
]
include:
- name: linuxmusl-x64
os: ubuntu-latest
BASE_IMAGE: library/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: x86_64
CMD: BuildAllCMD
COUNT: 19
NPMCOUNT: 7
- name: linuxmusl-arm
os: ubuntu-latest
BASE_IMAGE: arm32v6/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: arm
CMD: BuildAllCMD
COUNT: 19
NPMCOUNT: 7
- name: linuxmusl-arm64
os: ubuntu-latest
BASE_IMAGE: arm64v8/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: aarch64
CMD: BuildAllCMD
COUNT: 19
NPMCOUNT: 7
- name: linux-arm
os: ubuntu-latest
BASE_IMAGE: balenalib/raspberrypi3-debian:buster
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: arm
CMD: BuildAllCMD
COUNT: 19
NPMCOUNT: 7
# Builds for NodeJS 19+
- name: linux-x64
os: ubuntu-latest
BASE_IMAGE: library/debian:buster-slim
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: x86_64
CMD: BuildNewCMD
COUNT: 12
NPMCOUNT: 4
- name: linux-ia32
os: ubuntu-latest
BASE_IMAGE: i386/debian:buster-slim
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: i386
CMD: BuildNewCMD
COUNT: 12
NPMCOUNT: 4
- name: linux-arm64
os: ubuntu-latest
BASE_IMAGE: arm64v8/debian:buster-slim
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: aarch64
CMD: BuildNewCMD
COUNT: 12
NPMCOUNT: 4
# Builds for NodeJS 18 or lower
- name: linux-x64-older
os: ubuntu-latest
BASE_IMAGE: library/debian:9.6-slim
DOCKERFILE: Dockerfile.oldDebian
QEMU_ARCH: x86_64
CMD: BuildOldCMD
COUNT: 7
NPMCOUNT: 3
- name: linux-ia32-older
os: ubuntu-latest
BASE_IMAGE: i386/debian:9.6-slim
DOCKERFILE: Dockerfile.oldDebian
QEMU_ARCH: i386
CMD: BuildOldCMD
COUNT: 7
NPMCOUNT: 3
- name: linux-arm64-older
os: ubuntu-latest
BASE_IMAGE: arm64v8/debian:9.6-slim
DOCKERFILE: Dockerfile.oldDebian
QEMU_ARCH: aarch64
CMD: BuildOldCMD
COUNT: 7
NPMCOUNT: 3
# Other OS's
- name: darwin-x64
os: macOS-13
COUNT: 19
NPMCOUNT: 11
- name: darwin-arm64
os: macOS-14
COUNT: 19
NPMCOUNT: 11
- name: win32-ia32
os: windows-2019
arch: ia32
COUNT: 14
NPMCOUNT: 0
- name: win32-x64
os: windows-2019
arch: x64
COUNT: 19
NPMCOUNT: 0
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Linux - Setup Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get --yes --no-install-recommends install binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static:register --reset
# Hackery to setup builds
- name: Setup Build Commands
if: runner.os == 'Linux'
run: |
echo "BuildOldCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/electron.js ${oldElectronBuildTargets}\"" >> $GITHUB_ENV
echo "BuildNewCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${currentNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${currentNodeBuildTargets}&& \
./.prebuild/build.sh .prebuild/electron.js ${electronBuildTargets}\"" >> $GITHUB_ENV
echo "BuildAllCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${currentNodeBuildTargets} ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${currentNodeBuildTargets} ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/electron.js ${electronBuildTargets} ${oldElectronBuildTargets}\"" >> $GITHUB_ENV
echo "CMD=${{ matrix.CMD }}" >> $GITHUB_ENV
- name: Linux - Prep Build EXECCMD = ${{ env.CMD }}
if: runner.os == 'Linux'
run: |
echo "${{ env.CMD }}"
echo "EXECCMD=${!CMD}" >> $GITHUB_ENV
# Linux builds
- name: Linux - Build Docker Image ${{ matrix.DOCKERFILE }} - ${{ matrix.BASE_IMAGE }} - ${{ matrix.QEMU_ARCH }}
if: runner.os == 'Linux'
run: |
docker build -f .prebuild/${{ matrix.DOCKERFILE }} --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg QEMU_ARCH=${{ matrix.QEMU_ARCH }} -t multiarch-build .
- name: Linux - Prebuild Binaries - ${{ env.EXECCMD }}
if: runner.os == 'Linux'
run: |
docker run --rm -v $(pwd):/node-pty multiarch-build sh -c ${{ env.EXECCMD }}
# Mac OS
- name: macOS - Prebuild Binaries X64
if: ${{ (runner.os == 'macOS') && (runner.arch == 'X64') }}
run: |
python3 -m pip install packaging setuptools
npm ci --ignore-scripts
env JOBS=max node .prebuild/prebuild.js ${currentNodeBuildTargets} ${oldNodeBuildTargets}
env JOBS=max node .prebuild/electron.js ${electronBuildTargets} ${oldElectronBuildTargets}
# buildify doesn't work on Mac due to missing spawn_helper
# env JOBS=max node .prebuild/buildify.js
- name: macOS - Prebuild Binaries ARM64
if: ${{ (runner.os == 'macOS') && (runner.arch == 'ARM64') }}
run: |
python3 -m venv build
source build/bin/activate
python3 -m pip install packaging setuptools
brew install python-setuptools
npm ci --ignore-scripts
env JOBS=max node .prebuild/prebuild.js ${currentNodeBuildTargets} ${oldNodeBuildTargets}
env JOBS=max node .prebuild/electron.js ${electronBuildTargets} ${oldElectronBuildTargets}
# buildify doesn't work on Mac due to missing spawn_helper
# env JOBS=max node .prebuild/buildify.js
# Windows
- name: Windows ia32 - Prebuild Binaries
if: ${{ (runner.os == 'Windows') && (matrix.arch == 'ia32') }}
shell: bash
run: |
npm ci --ignore-scripts
env JOBS=max node_modules/.bin/prebuild ${winIA32nodeBuildTargets} --include-regex "\.(node|exe|dll|pdb)" --arch ${{ matrix.arch }}
env JOBS=max node_modules/.bin/prebuild ${winIA32electronBuildTargets} ${oldElectronBuildTargets} --include-regex "\.(node|exe|dll|pdb)" -r electron -a ${{ matrix.arch }}
- name: Windows x64 - Prebuild Binaries
if: ${{ (runner.os == 'Windows') && (matrix.arch == 'x64') }}
shell: bash
run: |
npm ci --ignore-scripts
env JOBS=max node_modules/.bin/prebuild ${currentNodeBuildTargets} ${oldNodeBuildTargets} --include-regex "\.(node|exe|dll|pdb)" --arch ${{ matrix.arch }}
env JOBS=max node_modules/.bin/prebuild ${electronBuildTargets} ${oldElectronBuildTargets} --include-regex "\.(node|exe|dll|pdb)" -r electron --arch ${{ matrix.arch }}
# Start of Checks
- name: Check Release prebuilds exist
shell: bash
run: |
fileCount=$(ls prebuilds/*/node-pty*tar.gz | wc -l)
echo "Release Prebuild count ${fileCount}"
if [ "$fileCount" -ne ${{ matrix.COUNT }} ]; then echo "::warning::Release Prebuild count ${fileCount}, expected ${{ matrix.COUNT }}"; else echo "::notice::Release Prebuild count ${fileCount}, expected ${{ matrix.COUNT }}"; fi
- name: "Check file existence"
id: check_files
uses: andstor/file-existence-action@v3
with:
files: "prebuilds/*/node*node"
- name: Check NPM prebuilds exist
if: steps.check_files.outputs.files_exists == 'true'
shell: bash
run: |
fileCount=$(ls prebuilds/*/node*node | wc -l)
echo "NPM Prebuild count ${fileCount}"
if [ "$fileCount" -ne ${{ matrix.NPMCOUNT }} ]; then echo "::warning::Release NPM Prebuild count ${fileCount}, expected ${{ matrix.NPMCOUNT }}"; else echo "::notice::Release NPM Prebuild count ${fileCount}, expected ${{ matrix.NPMCOUNT }}"; fi
- name: Create Archive of prebuilds
if: runner.os != 'Windows'
run: |
tar -czf archive.${{ matrix.name }}.tar.gz prebuilds/
- name: Create Archive of prebuilds
if: runner.os == 'Windows'
run: |
tar -czf archive.${{ matrix.name }}.tar.gz prebuilds
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
retention-days: 7
if-no-files-found: warn
path: |
archive.${{ matrix.name }}.tar.gz
publish:
name: Publish GitHub and NPM Release
needs: prebuild
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifacts/
- name: Extract prebuilds
run: |
for file in artifacts/archive.*.tar.gz; do
tar -xzf "$file"
done
- name: Display structure of downloaded files
run: ls -R
- name: NPM build
run: |
npm ci --ignore-scripts
npm run build
- name: Check Release prebuilds exist
shell: bash
run: |
fileCount=$(ls prebuilds/*/node-pty*tar.gz | wc -l)
echo "Release Prebuild count ${fileCount}"
echo "::notice::Release Prebuild count ${fileCount}"
# if [ "$fileCount" -ne ${ReleasePrebuildCount} ]; then echo "::error::Release Prebuild count ${fileCount}, expected ${ReleasePrebuildCount}"; exit 1; else echo "::notice::Release Prebuild count ${fileCount}, expected ${ReleasePrebuildCount}"; fi
- name: Check Release prebuildify`s exist
shell: bash
run: |
fileCount=$(ls prebuilds/*/*node | wc -l)
echo "Release prebuildify count ${fileCount}"
echo "::notice::Release prebuildify count ${fileCount}"
# if [ "$fileCount" -ne ${ReleasePrebuildifyCount} ]; then echo "::error::Release Prebuildify count ${fileCount}, expected ${ReleasePrebuildifyCount}"; exit 1; else echo "::notice::Release Prebuildify count ${fileCount}, expected ${ReleasePrebuildifyCount}"; fi
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package-version.outputs.current-version}}
release_name: Release v${{ steps.package-version.outputs.current-version}}
body: |
Changes in this Release
- First Change
- Second Change
draft: false
prerelease: true
- uses: AButler/upload-release-assets@v2.0
name: Upload Prebuild Artifacts to ${{ steps.package-version.outputs.current-version}}
with:
files: "prebuilds/*/node-pty*tar.gz"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ steps.package-version.outputs.current-version}}
- name: NPM Pack Release
run: |
npm pack
- uses: AButler/upload-release-assets@v2.0
name: Upload NPM Release to ${{ steps.package-version.outputs.current-version}}
with:
files: "*node-pty-prebuilt-multiarch*.tgz"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ steps.package-version.outputs.current-version}}
- name: "Check file existence"
id: check_files
uses: andstor/file-existence-action@v3
with:
files: "prebuilds/*/node-pty-prebuilt-multiarch-*-node-*-darwin-arm64.tar.gz"
- name: Check MacOS ARM prebuilds exist
if: steps.check_files.outputs.files_exists == 'false'
run: |
echo "::error::Missing MacOS ARM prebuilds, please correct, and rerun"
exit 1
- name: npm publish beta
if: ${{ github.repository == 'homebridge/node-pty-prebuilt-multiarch' && inputs.Beta }}
run: npm publish --access public --tag=beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: npm publish production
if: ${{ github.repository == 'homebridge/node-pty-prebuilt-multiarch' && ! inputs.Beta }}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Output Results"
run: |
echo "::notice:: Release Version: ${{ steps.package-version.outputs.current-version }}"