mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-24 13:36:31 +00:00
Unify release and dev GitHub actions (#2764)
Use a single workflow file for releases and dev builds. This avoids duplication and enhances the release builds with some of the recent improvements (e.g. shared build container).
This commit is contained in:
parent
49a487d4a2
commit
8d6b4eb11b
@ -1,8 +1,10 @@
|
||||
# Home Assistant Operating System build workflow
|
||||
|
||||
name: Development build
|
||||
name: OS build
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
boards:
|
||||
@ -21,6 +23,7 @@ jobs:
|
||||
outputs:
|
||||
version_main: ${{ steps.version_main.outputs.version_main }}
|
||||
version_dev: ${{ steps.version_dev.outputs.version_dev }}
|
||||
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 }}
|
||||
steps:
|
||||
@ -29,6 +32,26 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- 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)
|
||||
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 }})."
|
||||
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
|
||||
run: |
|
||||
@ -36,9 +59,23 @@ jobs:
|
||||
build=$(cat ${GITHUB_WORKSPACE}/buildroot-external/meta | grep VERSION_BUILD | cut -d'=' -f2)
|
||||
echo "version_main=${major}.${build}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Get channel
|
||||
id: channel
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "release" ]]; then
|
||||
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
|
||||
echo "channel=beta" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "channel=stable" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
else
|
||||
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}\""
|
||||
@ -50,6 +87,10 @@ jobs:
|
||||
with:
|
||||
script: |
|
||||
const boards = require('./.github/workflows/matrix.json')
|
||||
if ("${{ github.event_name }}" == "release") {
|
||||
return { "board": boards }
|
||||
}
|
||||
|
||||
const boardFilter = "${{ github.event.inputs.boards }}"
|
||||
if (boardFilter == "") {
|
||||
console.log("Run full build for all boards")
|
||||
@ -82,9 +123,11 @@ jobs:
|
||||
|
||||
build:
|
||||
name: Development build for ${{ matrix.board.id }}
|
||||
permissions:
|
||||
contents: write # for actions/upload-release-asset to upload release asset
|
||||
needs: prepare
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: ${{ github.event_name == 'release' }}
|
||||
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
@ -135,6 +178,7 @@ jobs:
|
||||
make BUILDDIR=/build VERSION_DEV=${{ needs.prepare.outputs.version_dev }} ${{ matrix.board.defconfig }}
|
||||
|
||||
- name: Upload images
|
||||
if: ${{ github.event_name != 'release' }}
|
||||
uses: burnett01/rsync-deployments@5.2
|
||||
with:
|
||||
rsh: -q
|
||||
@ -146,6 +190,13 @@ jobs:
|
||||
remote_user: ${{ secrets.DEV_USERNAME }}
|
||||
remote_key: ${{ secrets.DEV_SSH_KEY }}
|
||||
|
||||
- name: Upload release assets
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: output/images/haos_*
|
||||
|
||||
- name: Cache downloads
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
@ -172,10 +223,10 @@ jobs:
|
||||
email: ${{ secrets.GIT_EMAIL }}
|
||||
token: ${{ secrets.GIT_TOKEN }}
|
||||
|
||||
- name: Bump Home Assistant OS dev channel version to ${{ needs.prepare.outputs.version_main }}.${{ needs.prepare.outputs.version_dev }}
|
||||
- name: Bump Home Assistant OS ${{ needs.prepare.outputs.channel }} channel version
|
||||
uses: home-assistant/actions/helpers/version-push@master
|
||||
with:
|
||||
key: "hassos[]"
|
||||
key-description: "Home Assistant OS"
|
||||
version: ${{ needs.prepare.outputs.version_main }}.${{ needs.prepare.outputs.version_dev }}
|
||||
channel: "dev"
|
||||
channel: ${{ needs.prepare.outputs.channel }}
|
126
.github/workflows/release.yml
vendored
126
.github/workflows/release.yml
vendored
@ -1,126 +0,0 @@
|
||||
# Home Assistant Operating System release build workflow
|
||||
|
||||
name: Release build
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
validate_release:
|
||||
name: Validate release
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
version: ${{ steps.version_check.outputs.version }}
|
||||
version_dev: ${{ steps.version_check.outputs.version_dev }}
|
||||
matrix: ${{ steps.generate_matrix.outputs.result }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Validate version
|
||||
id: version_check
|
||||
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)
|
||||
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 }})."
|
||||
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: Create build matrix
|
||||
uses: actions/github-script@v6
|
||||
id: generate_matrix
|
||||
with:
|
||||
script: |
|
||||
const boards = require('./.github/workflows/matrix.json')
|
||||
return { "board": boards }
|
||||
|
||||
build:
|
||||
permissions:
|
||||
contents: write # for actions/upload-release-asset to upload release asset
|
||||
name: Release build for ${{ matrix.board.id }}
|
||||
needs: validate_release
|
||||
strategy:
|
||||
matrix: ${{ fromJson(needs.validate_release.outputs.matrix) }}
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- 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: Free space on build drive
|
||||
run: |
|
||||
# Inspired by https://github.com/easimon/maximize-build-space/blob/v7/action.yml
|
||||
sudo rm -rf /usr/local/lib/android/sdk/ndk
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
||||
# Make sure cache action can restore this lcoation
|
||||
sudo mkdir /mnt/cache
|
||||
sudo chown -R runner:runner /mnt/cache
|
||||
|
||||
- name: Cache downloads
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /mnt/cache/dl
|
||||
key: haos-dl
|
||||
|
||||
- name: Cache object files
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /mnt/cache/cc
|
||||
key: haos-cc-${{ matrix.board.architecture }}
|
||||
|
||||
- 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 "/mnt/cache:/cache" \
|
||||
haos-builder make BUILDDIR=/build VERSION_DEV=${{ needs.validate_release.outputs.version_dev }} ${{ matrix.board.defconfig }}
|
||||
|
||||
- name: Upload release assets
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: output/images/haos_*
|
||||
|
||||
bump_version:
|
||||
name: Bump dev version to ${{ needs.validate_release.outputs.version }}
|
||||
needs: [ build, validate_release ]
|
||||
runs-on: [ "ubuntu-20.04" ]
|
||||
|
||||
steps:
|
||||
- name: Initialize git
|
||||
uses: home-assistant/actions/helpers/git-init@master
|
||||
with:
|
||||
name: ${{ secrets.GIT_NAME }}
|
||||
email: ${{ secrets.GIT_EMAIL }}
|
||||
token: ${{ secrets.GIT_TOKEN }}
|
||||
|
||||
- name: Bump Home Assistant OS beta version
|
||||
uses: home-assistant/actions/helpers/version-push@master
|
||||
with:
|
||||
key: "hassos[]"
|
||||
key-description: "Home Assistant OS"
|
||||
version: ${{ needs.validate_release.outputs.version }}
|
||||
channel: "beta"
|
Loading…
x
Reference in New Issue
Block a user