diff --git a/.github/workflows/Build Only.yml b/.github/workflows/Build Only.yml new file mode 100644 index 0000000..24f311f --- /dev/null +++ b/.github/workflows/Build Only.yml @@ -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/update_release@v1.3.1 + 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/update_release@v1.3.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ github.event.inputs.version }} + with: + body_path: ${{ env.BODY_FILE }} + + - uses: AButler/upload-release-assets@v2.0.2 + with: + files: '*.deb;*.manifest' + repo-token: ${{ secrets.GITHUB_TOKEN }} + release-tag: ${{ github.event.inputs.version }} + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0866a66..43d0f82 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: @@ -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 @@ -36,6 +37,7 @@ jobs: needs: release runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: name: [ debian-x86_64, @@ -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/upload-release-assets@v2.0 + - name: Set variables + run: | + echo BODY_FILE="$(ls *.manifest)" >> $GITHUB_ENV + + - name: update release + uses: tubone24/update_release@v1.3.1 + 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/update_release@v1.3.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ github.event.inputs.version }} + with: + body_path: ${{ env.BODY_FILE }} + + - uses: AButler/upload-release-assets@v2.0.2 with: - files: '*.deb' + files: '*.deb;*.manifest' repo-token: ${{ secrets.GITHUB_TOKEN }} release-tag: ${{ github.event.inputs.version }} diff --git a/build.sh b/build.sh index d0c445a..4e51956 100755 --- a/build.sh +++ b/build.sh @@ -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} @@ -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" || @@ -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 diff --git a/deb/debian/preinst b/deb/debian/preinst index b58c994..03d7594 100755 --- a/deb/debian/preinst +++ b/deb/debian/preinst @@ -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."