Skip to content

Commit

Permalink
Adjust Home Assistant OS versioning to prepare for new release strate…
Browse files Browse the repository at this point in the history
…gy (home-assistant#2767)

* Adjust Home Assistant versioning to prepare for new release strategy

With OS 11 we'll create rc pre-releases which will get directly pushed
to the beta channel. In contrast, release builds will get directly
pushed to the stable channel.

Similar to Home Assistant Core we'll create bump commits for all stable
and beta releases. This makes sure that the source code matches the
built binaries for all releases.

The development build will get a generated version. To avoid issues
with the new rc builds the dev build version will get injected on source
level now.

* Apply suggestions from code review
  • Loading branch information
agners authored Sep 25, 2023
1 parent 7870a1d commit 3df2749
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 36 deletions.
72 changes: 44 additions & 28 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ jobs:
pull-requests: read
packages: write
outputs:
version_main: ${{ steps.version_main.outputs.version_main }}
version_dev: ${{ steps.version_dev.outputs.version_dev }}
version_main: ${{ steps.version.outputs.version_main }}
version_full: ${{ steps.version.outputs.version_full }}
channel: ${{ steps.channel.outputs.channel }}
matrix: ${{ steps.generate_matrix.outputs.result }}
build_container_image: ghcr.io/${{ github.repository_owner }}/haos-builder@${{ steps.build_haos_builder.outputs.digest }}
Expand All @@ -32,32 +33,49 @@ jobs:
with:
persist-credentials: false

- name: Generate development version
shell: bash
id: version_dev
if: ${{ github.event_name != 'release' }}
run: |
version_dev="dev$(date --utc +'%Y%m%d')"
echo "Development version \"${version_dev}\""
echo "version_dev=${version_dev}" >> $GITHUB_OUTPUT
- name: Set version suffix
if: ${{ github.event_name != 'release' }}
env:
VERSION_DEV: ${{ steps.version_dev.outputs.version_dev }}
run: |
sed -E "s/(^VERSION_SUFFIX=\").*(\"$)/\1${VERSION_DEV}\2/" buildroot-external/meta
- name: Validate version
id: version_check
if: ${{ github.event_name == 'release' }}
run: |
major=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_MAJOR | cut -d'=' -f2)
build=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_BUILD | cut -d'=' -f2)
minor=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_MINOR | cut -d'=' -f2)
suffix=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_SUFFIX | cut -d'=' -f2)
tag_major=$(echo "${{ github.event.release.tag_name }}" | cut -d '.' -f 1)
tag_build=$(echo "${{ github.event.release.tag_name }}" | cut -d '.' -f 2)
tag_dev=$(echo "${{ github.event.release.tag_name }}" | cut -d '.' -f 3)
if [ "${major}.${build}" != "${tag_major}.${tag_build}" ]; then
echo "Version number in Buildroot metadata is does not match tag (${major}.${build} vs ${{ github.event.release.tag_name }})."
tag_minor=$(echo "${{ github.event.release.tag_name }}" | cut -d '.' -f 2)
tag_suffix=$(echo "${{ github.event.release.tag_name }}" | cut -d '.' -f 3)
if [ "${major}.${minor}.${suffix}" != "${tag_major}.${tag_minor}.${tag_suffix}" ]; then
echo "Version number in Buildroot metadata does not match tag (${major}.${minor}.${suffix} vs ${{ github.event.release.tag_name }})."
exit 1
fi
if [ "" != "${tag_dev}" ]; then
echo "version=${major}.${build}.${tag_dev}" >> $GITHUB_OUTPUT
else
echo "version=${major}.${build}" >> $GITHUB_OUTPUT
fi
echo "version_dev=${tag_dev}" >> $GITHUB_OUTPUT
- name: Get Major/Minor version
id: version_main
- name: Get version
id: version
run: |
major=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_MAJOR | cut -d'=' -f2)
build=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_BUILD | cut -d'=' -f2)
echo "version_main=${major}.${build}" >> $GITHUB_OUTPUT
minor=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_MINOR | cut -d'=' -f2)
suffix=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_SUFFIX | cut -d'=' -f2)
echo "version_main=${major}.${minor}" >> $GITHUB_OUTPUT
if [ -z "${suffix}" ]; then
echo "version_full=${major}.${minor}" >> $GITHUB_OUTPUT
else
echo "version_full=${major}.${minor}.${suffix}" >> $GITHUB_OUTPUT
fi
- name: Get channel
id: channel
Expand All @@ -72,15 +90,6 @@ jobs:
echo "channel=dev" >> "$GITHUB_OUTPUT"
fi
- name: Generate Development build version
shell: bash
id: version_dev
if: ${{ github.event_name != 'release' }}
run: |
version_dev="dev$(date --utc +'%Y%m%d')"
echo "Development version \"${version_dev}\""
echo "version_dev=${version_dev}" >> $GITHUB_OUTPUT
- name: Create build matrix
uses: actions/github-script@v6
id: generate_matrix
Expand Down Expand Up @@ -138,6 +147,13 @@ jobs:
submodules: true
persist-credentials: false

- name: Set version suffix
if: ${{ github.event_name != 'release' }}
env:
VERSION_DEV: ${{ needs.prepare.outputs.version_dev }}
run: |
sed -E "s/(^VERSION_SUFFIX=\").*(\"$)/\1${VERSION_DEV}\2/" buildroot-external/meta
- name: 'Add release PKI certs'
env:
RAUC_CERTIFICATE: ${{ secrets.RAUC_CERTIFICATE }}
Expand Down Expand Up @@ -175,7 +191,7 @@ jobs:
-e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \
-v "/mnt/cache:/cache" \
${{ needs.prepare.outputs.build_container_image }} \
make BUILDDIR=/build VERSION_DEV=${{ needs.prepare.outputs.version_dev }} ${{ matrix.board.defconfig }}
make BUILDDIR=/build ${{ matrix.board.defconfig }}
- name: Upload images
if: ${{ github.event_name != 'release' }}
Expand All @@ -184,7 +200,7 @@ jobs:
rsh: -q
switches: -aW
path: output/images/haos_*
remote_path: ${{ secrets.DEV_TARGET_PATH }}/${{ needs.prepare.outputs.version_main }}.${{ needs.prepare.outputs.version_dev }}/
remote_path: ${{ secrets.DEV_TARGET_PATH }}/${{ needs.prepare.outputs.version_full }}/
remote_host: ${{ secrets.DEV_HOST }}
remote_port: ${{ secrets.DEV_PORT }}
remote_user: ${{ secrets.DEV_USERNAME }}
Expand Down Expand Up @@ -228,5 +244,5 @@ jobs:
with:
key: "hassos[]"
key-description: "Home Assistant OS"
version: ${{ needs.prepare.outputs.version_main }}.${{ needs.prepare.outputs.version_dev }}
version: ${{ needs.prepare.outputs.version_full }}
channel: ${{ needs.prepare.outputs.channel }}
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ BUILDDIR:=$(shell pwd)
BUILDROOT=$(BUILDDIR)/buildroot
BUILDROOT_EXTERNAL=$(BUILDDIR)/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)))
Expand Down Expand Up @@ -32,7 +30,7 @@ $(TARGETS_CONFIG): %-config:

$(TARGETS): %: %-config
@echo "build $@"
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) VERSION_DEV=$(VERSION_DEV)
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL)

# Do not clean when building for one target
ifneq ($(words $(filter $(TARGETS),$(MAKECMDGOALS))), 1)
Expand Down
5 changes: 3 additions & 2 deletions buildroot-external/meta
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VERSION_MAJOR=11
VERSION_BUILD=0
VERSION_MAJOR="11"
VERSION_MINOR="0"
VERSION_SUFFIX="dev0"

HASSOS_NAME="Home Assistant OS"
HASSOS_ID="haos"
Expand Down
6 changes: 3 additions & 3 deletions buildroot-external/scripts/name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function hassos_rauc_compatible() {
}

function hassos_version() {
if [ -z "${VERSION_DEV}" ]; then
echo "${VERSION_MAJOR}.${VERSION_BUILD}"
if [ -z "${VERSION_SUFFIX}" ]; then
echo "${VERSION_MAJOR}.${VERSION_MINOR}"
else
echo "${VERSION_MAJOR}.${VERSION_BUILD}.${VERSION_DEV}"
echo "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_SUFFIX}"
fi
}

Expand Down

0 comments on commit 3df2749

Please sign in to comment.