Skip to content

Commit

Permalink
Update build process to hold at NodeJS 18.x stream, and create manife…
Browse files Browse the repository at this point in the history
…st file (#14)

* Create Build Only.yml

* Update Build Only.yml

* Update Build Only.yml

* Update Build Only.yml

* Update Build Only.yml

* Update preinst

* Update build process to hold at NodeJS 18.x stream, and create manifest file

Update build process to hold at NodeJS 18.x stream, and create manifest file
  • Loading branch information
NorthernMan54 authored Nov 9, 2023
1 parent ff357a8 commit e705e63
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 6 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/Build Only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: "Build Only"
run-name: Build Release ${{ github.event.inputs.version }} from ${{ github.ref_name }}

on:
workflow_dispatch:
inputs:
version:
description: 'Version / Tag (x.x.x):'
required: true
release_type:
type: choice
description: Release Type
options:
- stable
- test

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: ${{ github.event.inputs.version }}
prerelease: false

build:
name: Build Packages
needs: release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [
debian-x86_64,
debian-arm32v6,
debian-arm64v8,
]
include:
- name: debian-x86_64
os: ubuntu-latest
BASE_IMAGE: library/debian:bullseye
QEMU_ARCH: x86_64

- name: debian-arm32v6
os: ubuntu-latest
BASE_IMAGE: balenalib/raspberry-pi-debian:bullseye
QEMU_ARCH: arm

- name: debian-arm64v8
os: ubuntu-latest
BASE_IMAGE: arm64v8/debian:bullseye
QEMU_ARCH: aarch64

steps:
- uses: actions/checkout@v3

- 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
- name: Linux - Build Docker Image
if: runner.os == 'Linux'
run: |
docker build -f build/Dockerfile --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg QEMU_ARCH=${{ matrix.QEMU_ARCH }} -t package-build .
- name: Linux - Build Package
if: runner.os == 'Linux'
run: |
docker run --rm -v $(pwd):/repo -e PKG_RELEASE_TYPE="${{ github.event.inputs.release_type }}" -e PKG_RELEASE_VERSION="${{ github.event.inputs.version }}" package-build
- name: List files
run: |
find . -print
- name: Set variables
run: |
echo BODY_FILE="$(ls *.manifest)" >> $GITHUB_ENV
- name: update release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.event.inputs.version }}
with:
is_append_body: "Contents of ${{ matrix.QEMU_ARCH }} Package."

- name: update release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.event.inputs.version }}
with:
body_path: ${{ env.BODY_FILE }}

- uses: AButler/[email protected]
with:
files: '*.deb;*.manifest'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.event.inputs.version }}

30 changes: 26 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: "Build and Deploy Packages"
name: "Build Release and Publish to DEB Repo"
run-name: Build Release ${{ github.event.inputs.version }} from ${{ github.ref_name }}

on:
workflow_dispatch:
Expand All @@ -19,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create Release
id: create_release
Expand All @@ -36,6 +37,7 @@ jobs:
needs: release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [
debian-x86_64,
Expand Down Expand Up @@ -78,9 +80,29 @@ jobs:
run: |
docker run --rm -v $(pwd):/repo -e PKG_RELEASE_TYPE="${{ github.event.inputs.release_type }}" -e PKG_RELEASE_VERSION="${{ github.event.inputs.version }}" package-build
- uses: AButler/[email protected]
- name: Set variables
run: |
echo BODY_FILE="$(ls *.manifest)" >> $GITHUB_ENV
- name: update release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.event.inputs.version }}
with:
is_append_body: "Contents of ${{ matrix.QEMU_ARCH }} Package."

- name: update release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.event.inputs.version }}
with:
body_path: ${{ env.BODY_FILE }}

- uses: AButler/[email protected]
with:
files: '*.deb'
files: '*.deb;*.manifest'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.event.inputs.version }}

Expand Down
27 changes: 25 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ fi
rm -rf staging
cp -R deb staging

NODE_VERSION="$(curl -s https://nodejs.org/dist/index.json | jq -r 'map(select(.lts))[0].version')"
# Hold the NodeJS version to the 18.x LTS stream until spring of 2024, then switch to `Iron` aka 20.0 LTS

NODE_LTS_TAG="Hydrogen"
NODE_VERSION="$(curl -s https://nodejs.org/dist/index.json | jq -r --arg NODE_LTS_TAG "${NODE_LTS_TAG}" 'map(select(.lts==$NODE_LTS_TAG))[0].version')"



BUILD_ARCH=${QEMU_ARCH:-x86_64}

Expand All @@ -27,6 +32,12 @@ case "$BUILD_ARCH" in \
*) echo "unsupported architecture"; exit 1 ;;
esac

echo "Homebridge Apt Package Manifest" > homebridge_apt_pkg_$NODE_ARCH.manifest
echo >> homebridge_apt_pkg_$NODE_ARCH.manifest
echo "| Package | Version |" >> homebridge_apt_pkg_$NODE_ARCH.manifest
echo "|:-------:|:-------:|" >> homebridge_apt_pkg_$NODE_ARCH.manifest
echo "|NodeJS| "$NODE_VERSION "|" >> homebridge_apt_pkg_$NODE_ARCH.manifest

if [ ! -f "node-$NODE_VERSION-linux-$NODE_ARCH.tar.gz" ]; then
[ "$NODE_ARCH" = "armv6l" -o "$NODE_ARCH" = "x86" ] &&
curl -SLO "https://unofficial-builds.nodejs.org/download/release/$NODE_VERSION/node-$NODE_VERSION-linux-$NODE_ARCH.tar.gz" ||
Expand All @@ -47,7 +58,19 @@ export npm_config_loglevel=error

npm install --location=global homebridge-config-ui-x@latest

HOMBRIDGE_CONFIG_VERSION="$(npm list -g --json=true | jq --raw-output '{version: .dependencies."homebridge-config-ui-x".version}.version')"
echo "|Homebridge-Config-UI-X|" $HOMBRIDGE_CONFIG_VERSION "|" >> homebridge_apt_pkg_$NODE_ARCH.manifest

npm install --prefix $(pwd)/staging/var/lib/homebridge homebridge@latest

cd staging
CWD=`pwd`
cd staging/var/lib/homebridge
HOMBRIDGE_VERSION="$(npm list --json=true | jq --raw-output '{version: .dependencies."homebridge".version}.version')"
echo "|Homebridge|" $HOMBRIDGE_VERSION "|" >> ${CWD}/homebridge_apt_pkg_$NODE_ARCH.manifest

cd ${CWD}/staging
dpkg-buildpackage -us -uc

cd ${CWD}
MANIFEST=$(ls homebridge*.deb | sed -e 's/.deb/.manifest/g')
mv ${CWD}/homebridge_apt_pkg_$NODE_ARCH.manifest ${CWD}/$MANIFEST
3 changes: 3 additions & 0 deletions deb/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ if [ "$1" = "upgrade" ] && [ $2 ]; then
rm -rf /var/lib/homebridge/pnpm-lock.yaml
rm -rf /var/lib/homebridge/package.json
rm -rf /var/lib/homebridge/.npmrc
# cleanup node-pty-prebuilt-multiarch
rm -rf /opt/homebridge/lib/node_modules/homebridge-config-ui-x/node_modules/node-pty-prebuilt-multiarch/build
rm -rf /opt/homebridge/lib/node_modules/homebridge-config-ui-x/node_modules/@homebridge/node-pty-prebuilt-multiarch/build
fi

echo "Unpacking may take several minutes on low powered devices."
Expand Down

0 comments on commit e705e63

Please sign in to comment.