Adjust Home Assistant OS versioning to prepare for new release strategy (#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
This commit is contained in:
Stefan Agner 2023-09-25 13:41:50 +02:00 committed by GitHub
parent 7870a1d78e
commit 3df2749171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 36 deletions

View File

@ -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 }}
@ -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
@ -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
@ -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 }}
@ -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' }}
@ -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 }}
@ -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 }}

View File

@ -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)))
@ -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)

View File

@ -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"

View File

@ -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
}