Skip to content

Package against beta-0.12.0 #71

Package against beta-0.12.0

Package against beta-0.12.0 #71

name: "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 18.0.0 -t 17.0.1 -t 16.0.0
nodeBuildTargets: -t 23.0.0 -t 22.0.0 -t 21.0.0 -t 20.0.0 -t 19.0.0
oldElectronBuildTargets: -t 19.0.0 -t 18.0.0 -t 17.0.0 -t 16.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 -t 16.0.0
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: 204
ReleasePrebuildifyCount: 49
jobs:
Prepare_prebuild_environment:
name: Prepare prebuild environment ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- name: Delete pr-* branches
uses: homebridge/action-delete-branch@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: "release-candidate"
- uses: actions/checkout@v4
- name: Create Branch
uses: peterjgrainger/action-create-branch@v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Fetch Adjust version script
if: ${{ inputs.Beta }}
run: wget https://raw.githubusercontent.com/homebridge/.github/latest/.github/npm-version-script.js
working-directory: .github
- if: ${{ inputs.Beta }}
run: npm install semver
- name: Adjust version
if: ${{ inputs.Beta }}
run: node .github/npm-version-script.js ${{ github.ref }} beta
- name: npm version (without git commit)
if: ${{ inputs.Beta }}
run: npm version pre --preid=beta --no-git-tag-version
- name: Allow prebuilds to be stored on github
run: sed -i.bak '/prebuilds/d' .gitignore
- name: Commit & Push changes
uses: actions-js/push@master
with:
author_name: ${{ github.actor }}
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "release-candidate"
message: "Prepare prebuild environment ${{ github.ref_name }}"
rebase: true
prebuild:
name: ${{ matrix.name }} - Prebuild NPM and GitHub Release artifacts
needs: Prepare_prebuild_environment
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: 20
NPMCOUNT: 7
- name: linuxmusl-arm
os: ubuntu-latest
BASE_IMAGE: arm32v6/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: arm
CMD: BuildAllCMD
COUNT: 20
NPMCOUNT: 7
- name: linuxmusl-arm64
os: ubuntu-latest
BASE_IMAGE: arm64v8/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: aarch64
CMD: BuildAllCMD
COUNT: 20
NPMCOUNT: 7
- name: linux-arm
os: ubuntu-latest
BASE_IMAGE: balenalib/raspberry-pi-debian:buster
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: arm
CMD: BuildAllCMD
COUNT: 20
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: 20
NPMCOUNT: 11
- name: darwin-arm64
os: macOS-14
COUNT: 20
NPMCOUNT: 11
- name: win32-ia32
os: windows-2019
arch: ia32
COUNT: 14
NPMCOUNT: 0
- name: win32-x64
os: windows-2019
arch: x64
COUNT: 20
NPMCOUNT: 0
steps:
- uses: actions/checkout@v4
with:
ref: "release-candidate"
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: get-npm-version
if: runner.os == 'Linux'
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- 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 ${nodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${nodeBuildTargets}&& \
./.prebuild/build.sh .prebuild/electron.js ${electronBuildTargets}\"" >> $GITHUB_ENV
echo "BuildAllCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${nodeBuildTargets} ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${nodeBuildTargets} ${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 ${nodeBuildTargets} ${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 ${nodeBuildTargets} ${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 ${nodeBuildTargets} ${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
- if: runner.os == 'Linux'
run: sudo chown -R $USER:$USER .
- name: Commit & Push changes
uses: actions-js/push@master
with:
author_name: ${{ github.actor }}
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "release-candidate"
message: "Prebuilds for ${{ steps.package-version.outputs.current-version}} - ${{ matrix.name }}"
rebase: true
publish:
name: Publish GitHub and NPM Release
needs: prebuild
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: "release-candidate"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
cache: "npm"
- 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}"
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 Prebuild 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 "Missing MacOS ARM prebuilds, please remove release Artifats, and reun"
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 }}