Skip to content

Commit

Permalink
JetHome: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
adeepn committed Mar 25, 2024
1 parent 8107e15 commit 94aa88c
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 112 deletions.
207 changes: 112 additions & 95 deletions .github/workflows/jh-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ env:
BUILD_TYPE: core
DEFAULT_PYTHON: "3.12"
PIP_TIMEOUT: 60
UV_HTTP_TIMEOUT: 60
UV_SYSTEM_PYTHON: "true"

jobs:
init:
Expand All @@ -25,7 +27,7 @@ jobs:
publish: ${{ steps.version.outputs.publish }}
steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
fetch-depth: 0

Expand All @@ -52,48 +54,6 @@ jobs:
with:
ignore-dev: true

build_python:
name: Build PyPi package
needs: ["init", "build_base"]
runs-on: ${{ vars.RUNNER }}
if: 0 # github.repository_owner == 'jethub-homeassistant' && needs.init.outputs.publish == 'true'
steps:
- name: Checkout the repository
uses: actions/[email protected]

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Download Translations
uses: transifex/cli-action@v2
with:
token: ${{ secrets.TX_TOKEN }}
args: pull -s -t -a

- name: Write Translations
run: python3 -m script.jhtranslations download

- name: Build package
shell: bash
run: |
# Remove dist, build, and homeassistant.egg-info
# when build locally for testing!
pip install twine build
python -m build
- name: Upload package
shell: bash
run: |
export TWINE_USERNAME="__token__"
export TWINE_PASSWORD="${{ secrets.TWINE_TOKEN }}"
twine upload dist/* --skip-existing
cache_translations:
name: Cache translations
if: github.repository_owner == 'jethub-homeassistant'
Expand All @@ -105,7 +65,7 @@ jobs:
id-token: write
steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml
Expand Down Expand Up @@ -149,18 +109,19 @@ jobs:
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures) }}
steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml

- name: Download nightly wheels of frontend
if: needs.init.outputs.channel == 'dev'
uses: dawidd6/action-download-artifact@v3.0.0
uses: dawidd6/action-download-artifact@v3.1.4
with:
github_token: ${{secrets.GITHUB_TOKEN}}
repo: home-assistant/frontend
Expand All @@ -171,7 +132,7 @@ jobs:

- name: Download nightly wheels of intents
if: needs.init.outputs.channel == 'dev'
uses: dawidd6/action-download-artifact@v3.0.0
uses: dawidd6/action-download-artifact@v3.1.4
with:
github_token: ${{secrets.GITHUB_TOKEN}}
repo: home-assistant/intents-package
Expand All @@ -197,8 +158,9 @@ jobs:
if: needs.init.outputs.channel == 'dev'
shell: bash
run: |
python3 -m pip install packaging tomli
python3 -m pip install .
python3 -m pip install "$(grep '^uv' < requirements_test.txt)"
uv pip install packaging tomli
uv pip install .
version="$(python3 script/version_bump.py nightly)"
if [[ "$(ls home_assistant_frontend*.whl)" =~ ^home_assistant_frontend-(.*)-py3-none-any.whl$ ]]; then
Expand All @@ -211,7 +173,7 @@ jobs:
sed -i "s|home-assistant-frontend==.*|home-assistant-frontend==${BASH_REMATCH[1]}|" \
homeassistant/package_constraints.txt
python -m script.gen_requirements_all
sed -i "s|home-assistant-frontend==.*||" requirements_all.txt
fi
if [[ "$(ls home_assistant_intents*.whl)" =~ ^home_assistant_intents-(.*)-py3-none-any.whl$ ]]; then
Expand All @@ -229,7 +191,7 @@ jobs:
sed -i "s|home-assistant-intents==.*|home-assistant-intents==${BASH_REMATCH[1]}|" \
homeassistant/package_constraints.txt
python -m script.gen_requirements_all
sed -i "s|home-assistant-intents==.*||" requirements_all.txt
fi
- name: Adjustments for armhf
Expand All @@ -244,6 +206,15 @@ jobs:
sed -i "s|pyezviz|# pyezviz|g" requirements_all.txt
sed -i "s|pykrakenapi|# pykrakenapi|g" requirements_all.txt
- name: Adjustments for 64-bit
if: matrix.arch == 'amd64' || matrix.arch == 'aarch64'
run: |
# Some speedups are only available on 64-bit, and since
# we build 32bit images on 64bit hosts, we only enable
# the speed ups on 64bit since the wheels for 32bit
# are not available.
sed -i "s|aiohttp-zlib-ng|aiohttp-zlib-ng\[isal\]|g" requirements_all.txt
- name: create dir for translations
run: |
mkdir -p build/translations-download
Expand Down Expand Up @@ -282,14 +253,14 @@ jobs:
echo "${{ github.sha }};${{ github.ref }};${{ github.event_name }};${{ github.actor }}" > rootfs/OFFICIAL_IMAGE
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build base image
uses: jethub-homeassistant/builder@2024.01.0
uses: jethub-homeassistant/builder@2024.03.5
with:
args: |
$BUILD_ARGS \
Expand Down Expand Up @@ -334,7 +305,7 @@ jobs:
- qemux86-64
steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml
Expand All @@ -351,14 +322,14 @@ jobs:
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build base image
uses: jethub-homeassistant/builder@2024.01.0
uses: jethub-homeassistant/builder@2024.03.5
with:
args: |
$BUILD_ARGS \
Expand All @@ -373,7 +344,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml
Expand Down Expand Up @@ -411,26 +382,32 @@ jobs:
contents: read
packages: write
id-token: write
strategy:
matrix:
registry: ["ghcr.io/jethub-homeassistant", "docker.io/jethubjhaos"]

steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: Install Cosign
uses: sigstore/[email protected]
with:
cosign-release: "v2.0.2"
cosign-release: "v2.2.3"

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml

- name: Login to DockerHub
uses: docker/[email protected]
if: matrix.registry == 'docker.io/jethubjhaos'
uses: docker/[email protected]
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/[email protected]
if: matrix.registry == 'ghcr.io/jethub-homeassistant'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -444,41 +421,37 @@ jobs:
function create_manifest() {
local tag_l=${1}
local tag_r=${2}
local registry=${{ matrix.registry }}
for registry in "ghcr.io/jethub-homeassistant" "docker.io/jethubjhaos"
do
docker manifest create "${registry}/home-assistant:${tag_l}" \
"${registry}/amd64-homeassistant:${tag_r}" \
"${registry}/i386-homeassistant:${tag_r}" \
"${registry}/armhf-homeassistant:${tag_r}" \
"${registry}/armv7-homeassistant:${tag_r}" \
"${registry}/aarch64-homeassistant:${tag_r}"
docker manifest create "${registry}/home-assistant:${tag_l}" \
"${registry}/amd64-homeassistant:${tag_r}" \
"${registry}/i386-homeassistant:${tag_r}" \
"${registry}/armhf-homeassistant:${tag_r}" \
"${registry}/armv7-homeassistant:${tag_r}" \
"${registry}/aarch64-homeassistant:${tag_r}"
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/amd64-homeassistant:${tag_r}" \
--os linux --arch amd64
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/amd64-homeassistant:${tag_r}" \
--os linux --arch amd64
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/i386-homeassistant:${tag_r}" \
--os linux --arch 386
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/i386-homeassistant:${tag_r}" \
--os linux --arch 386
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/armhf-homeassistant:${tag_r}" \
--os linux --arch arm --variant=v6
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/armhf-homeassistant:${tag_r}" \
--os linux --arch arm --variant=v6
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/armv7-homeassistant:${tag_r}" \
--os linux --arch arm --variant=v7
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/armv7-homeassistant:${tag_r}" \
--os linux --arch arm --variant=v7
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/aarch64-homeassistant:${tag_r}" \
--os linux --arch arm64 --variant=v8
docker manifest annotate "${registry}/home-assistant:${tag_l}" \
"${registry}/aarch64-homeassistant:${tag_r}" \
--os linux --arch arm64 --variant=v8
docker manifest push --purge "${registry}/home-assistant:${tag_l}"
cosign sign --yes "${registry}/home-assistant:${tag_l}"
done
docker manifest push --purge "${registry}/home-assistant:${tag_l}"
cosign sign --yes "${registry}/home-assistant:${tag_l}"
}
function validate_image() {
Expand Down Expand Up @@ -511,12 +484,14 @@ jobs:
validate_image "ghcr.io/jethub-homeassistant/armv7-homeassistant:${{ needs.init.outputs.version }}"
validate_image "ghcr.io/jethub-homeassistant/aarch64-homeassistant:${{ needs.init.outputs.version }}"
# Upload images to dockerhub
push_dockerhub "amd64-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "i386-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "armhf-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "armv7-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "aarch64-homeassistant" "${{ needs.init.outputs.version }}"
if [[ "${{ matrix.registry }}" == "docker.io/jethubjhaos" ]]; then
# Upload images to dockerhub
push_dockerhub "amd64-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "i386-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "armhf-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "armv7-homeassistant" "${{ needs.init.outputs.version }}"
push_dockerhub "aarch64-homeassistant" "${{ needs.init.outputs.version }}"
fi
# Create version tag
create_manifest "${{ needs.init.outputs.version }}" "${{ needs.init.outputs.version }}"
Expand All @@ -537,3 +512,45 @@ jobs:
v="${{ needs.init.outputs.version }}"
create_manifest "${v%.*}" "${{ needs.init.outputs.version }}"
fi
build_python:
name: Build PyPi package
needs: ["init", "build_base"]
runs-on: ${{ vars.RUNNER }}
if: 0 # github.repository_owner == 'jethub-homeassistant' && needs.init.outputs.publish == 'true'
steps:
- name: Checkout the repository
uses: actions/[email protected]

- name: update build.yaml
run: cp -f build-jethub.yaml build.yaml

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Download Translations
uses: transifex/cli-action@v2
with:
token: ${{ secrets.TX_TOKEN }}
args: pull -s -t -a

- name: Write Translations
run: python3 -m script.jhtranslations download

- name: Build package
shell: bash
run: |
# Remove dist, build, and homeassistant.egg-info
# when build locally for testing!
pip install twine build
python -m build
- name: Upload package
shell: bash
run: |
export TWINE_USERNAME="__token__"
export TWINE_PASSWORD="${{ secrets.TWINE_TOKEN }}"
twine upload dist/* --skip-existing
2 changes: 1 addition & 1 deletion .github/workflows/jh-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ${{ vars.RUNNER }}
steps:
- name: Checkout the repository
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
Expand Down
Loading

0 comments on commit 94aa88c

Please sign in to comment.