From 4be3dee0b4e774ed44d295f710329a26a6722ae8 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 25 Nov 2020 10:52:28 +0100 Subject: [PATCH] Add dev build workflow (#1017) * Add development build version part to version number Add third part in the version number to indicate development builds. Generate a default version number based on the date, e.g. "5.6.dev20201124". * Add GitHub Action workflow for development builds Add another GitHub workflow for development builds. Make it triggered only for now. The version number is generated by the workflow and passed to all builds to make sure all builds have the same development build version. * Add documentation --- .github/workflows/dev.yml | 80 ++++++++++++++++++++++++ Makefile | 4 +- README.md | 6 ++ buildroot-external/scripts/name.sh | 8 ++- buildroot-external/scripts/post-build.sh | 8 +-- 5 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/dev.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 000000000..0cfe1bdb5 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,80 @@ +# Home Assistant Operating System build workflow + +name: Development build + +on: + workflow_dispatch: + +jobs: + version: + + name: Generate version + runs-on: [ "ubuntu-20.04" ] + outputs: + version_dev: ${{ steps.version.outputs.version_dev }} + steps: + - name: Generate Development build version + shell: bash + id: version + run: | + version_dev="dev$(date --utc +'%Y%m%d')" + echo "Development version \"${version_dev}\"" + echo "::set-output name=version_dev::${version_dev}" + + build: + name: Release build for ${{ matrix.board.name }} + needs: version + strategy: + matrix: + board: + - {"name": "ova", "output": "ova", "runner": "x86-64-runner"} + - {"name": "intel_nuc", "output": "intel-nuc", "runner": "x86-64-runner"} + - {"name": "odroid_c2", "output": "odroid-c2", "runner": "aarch64-runner"} + - {"name": "odroid_c4", "output": "odroid-c4", "runner": "aarch64-runner"} + - {"name": "odroid_n2", "output": "odroid-n2", "runner": "aarch64-runner"} + - {"name": "odroid_xu4", "output": "odroid-xu4" , "runner": "aarch64-runner"} + - {"name": "rpi", "output": "rpi", "runner": "arm-runner"} + - {"name": "rpi0_w", "output": "rpi0-w", "runner": "arm-runner"} + - {"name": "rpi2", "output": "rpi2", "runner": "arm-runner"} + - {"name": "rpi3", "output": "rpi3", "runner": "arm-runner"} + - {"name": "rpi3_64", "output": "rpi3-64", "runner": "aarch64-runner"} + - {"name": "rpi4", "output": "rpi4", "runner": "arm-runner"} + - {"name": "rpi4_64", "output": "rpi4-64", "runner": "aarch64-runner"} + - {"name": "tinker", "output": "tinker", "runner": "arm-runner"} + runs-on: ${{ matrix.board.runner }} + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Build container + run: docker build -t haos-builder . + + - name: 'Add release PKI certs' + env: + RAUC_CERTIFICATE: ${{ secrets.RAUC_CERTIFICATE }} + RAUC_PRIVATE_KEY: ${{ secrets.RAUC_PRIVATE_KEY }} + run: | + echo -e "-----BEGIN CERTIFICATE-----\n${RAUC_CERTIFICATE}\n-----END CERTIFICATE-----" > cert.pem + echo -e "-----BEGIN PRIVATE KEY-----\n${RAUC_PRIVATE_KEY}\n-----END PRIVATE KEY-----" > key.pem + + - name: Build + run: | + BUILDER_UID="$(id -u)" + BUILDER_GID="$(id -g)" + docker run --rm --privileged -v "${GITHUB_WORKSPACE}:/build" \ + -e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \ + -v "${{ matrix.board.runner }}-build-cache:/cache" \ + haos-builder make VERSION_DEV=${{ needs.version.outputs.version_dev }} ${{ matrix.board.name }} + + - name: Upload images + uses: appleboy/scp-action@master + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + port: ${{ secrets.DEV_PORT }} + key: ${{ secrets.DEV_SCP_KEY }} + source: "release/*" + target: ${{ secrets.DEV_TARGET_PATH }} + strip_components: 1 + diff --git a/Makefile b/Makefile index 4aabfb2d1..94256c9ab 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ RELEASE_DIR = /build/release BUILDROOT=/build/buildroot BUILDROOT_EXTERNAL=/build/buildroot-external DEFCONFIG_DIR = $(BUILDROOT_EXTERNAL)/configs +VERSION_DATE := $(shell date --utc +'%Y%m%d') +VERSION_DEV := "dev$(VERSION_DATE)" TARGETS := $(notdir $(patsubst %_defconfig,%,$(wildcard $(DEFCONFIG_DIR)/*_defconfig))) TARGETS_CONFIG := $(notdir $(patsubst %_defconfig,%-config,$(wildcard $(DEFCONFIG_DIR)/*_defconfig))) @@ -29,7 +31,7 @@ $(TARGETS_CONFIG): %-config: $(TARGETS): %: $(RELEASE_DIR) %-config @echo "build $@" - $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) VERSION_DEV=$(VERSION_DEV) cp -f $(O)/images/hassos_* $(RELEASE_DIR)/ # Do not clean when building for one target diff --git a/README.md b/README.md index 64acb832d..883de7e12 100644 --- a/README.md +++ b/README.md @@ -50,3 +50,9 @@ If you don't have experience with these, embedded systems, buildroot or the buil ## Developer Documentation All developer documentation is in the [Documentation](./Documentation) directory. + +### Development builds + +The Development build GitHub Action Workflow is a manually triggered workflow +which creates Home Assistant OS development builds. The development builds are +available at [os-builds.home-assistant.io](https://os-builds.home-assistant.io/). diff --git a/buildroot-external/scripts/name.sh b/buildroot-external/scripts/name.sh index 383bc19f4..6c5192461 100755 --- a/buildroot-external/scripts/name.sh +++ b/buildroot-external/scripts/name.sh @@ -1,7 +1,7 @@ #!/bin/bash function hassos_image_name() { - echo "${BINARIES_DIR}/${HASSOS_ID}_${BOARD_ID}-${VERSION_MAJOR}.${VERSION_BUILD}.${1}" + echo "${BINARIES_DIR}/${HASSOS_ID}_${BOARD_ID}-$(hassos_version).${1}" } function hassos_rauc_compatible() { @@ -9,7 +9,11 @@ function hassos_rauc_compatible() { } function hassos_version() { - echo "${VERSION_MAJOR}.${VERSION_BUILD}" + if [ -z "${VERSION_DEV}" ]; then + echo "${VERSION_MAJOR}.${VERSION_BUILD}" + else + echo "${VERSION_MAJOR}.${VERSION_BUILD}.${VERSION_DEV}" + fi } function path_spl_img() { diff --git a/buildroot-external/scripts/post-build.sh b/buildroot-external/scripts/post-build.sh index 029b41d24..f4c23efea 100755 --- a/buildroot-external/scripts/post-build.sh +++ b/buildroot-external/scripts/post-build.sh @@ -22,11 +22,11 @@ install_hassos_cli # shellcheck disable=SC2153 ( echo "NAME=${HASSOS_NAME}" - echo "VERSION=\"${VERSION_MAJOR}.${VERSION_BUILD} (${BOARD_NAME})\"" + echo "VERSION=\"$(hassos_version) (${BOARD_NAME})\"" echo "ID=${HASSOS_ID}" - echo "VERSION_ID=${VERSION_MAJOR}.${VERSION_BUILD}" - echo "PRETTY_NAME=\"${HASSOS_NAME} ${VERSION_MAJOR}.${VERSION_BUILD}\"" - echo "CPE_NAME=cpe:2.3:o:home_assistant:${HASSOS_ID}:${VERSION_MAJOR}.${VERSION_BUILD}:*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*" + echo "VERSION_ID=$(hassos_version)" + echo "PRETTY_NAME=\"${HASSOS_NAME} $(hassos_version)\"" + echo "CPE_NAME=cpe:2.3:o:home_assistant:${HASSOS_ID}:$(hassos_version):*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*" echo "HOME_URL=https://hass.io/" echo "VARIANT=\"${HASSOS_NAME} ${BOARD_NAME}\"" echo "VARIANT_ID=${BOARD_ID}"