From 94aa88c6581b6ac38a872ddd5a1940d709ecd9aa Mon Sep 17 00:00:00 2001 From: Viacheslav Bocharov Date: Mon, 25 Mar 2024 15:23:38 +0300 Subject: [PATCH] JetHome: update workflows --- .github/workflows/jh-builder.yml | 207 ++++++++++++++------------ .github/workflows/jh-translations.yml | 2 +- .github/workflows/jh-wheels.yml | 24 +-- build-jethub.yaml | 10 +- 4 files changed, 131 insertions(+), 112 deletions(-) diff --git a/.github/workflows/jh-builder.yml b/.github/workflows/jh-builder.yml index 43c8f1d6630660..7513e04f21628c 100644 --- a/.github/workflows/jh-builder.yml +++ b/.github/workflows/jh-builder.yml @@ -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: @@ -25,7 +27,7 @@ jobs: publish: ${{ steps.version.outputs.publish }} steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 with: fetch-depth: 0 @@ -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/checkout@v4.1.1 - - - name: update build.yaml - run: cp -f build-jethub.yaml build.yaml - - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v5.0.0 - 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' @@ -105,7 +65,7 @@ jobs: id-token: write steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: update build.yaml run: cp -f build-jethub.yaml build.yaml @@ -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/checkout@v4.1.1 + uses: actions/checkout@v4.1.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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 \ @@ -334,7 +305,7 @@ jobs: - qemux86-64 steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: update build.yaml run: cp -f build-jethub.yaml build.yaml @@ -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 \ @@ -373,7 +344,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: update build.yaml run: cp -f build-jethub.yaml build.yaml @@ -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/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: Install Cosign uses: sigstore/cosign-installer@v3.4.0 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/login-action@v3.0.0 + if: matrix.registry == 'docker.io/jethubjhaos' + uses: docker/login-action@v3.1.0 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v3.0.0 + if: matrix.registry == 'ghcr.io/jethub-homeassistant' + uses: docker/login-action@v3.1.0 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -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() { @@ -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 }}" @@ -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/checkout@v4.1.2 + + - name: update build.yaml + run: cp -f build-jethub.yaml build.yaml + + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + uses: actions/setup-python@v5.0.0 + 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 diff --git a/.github/workflows/jh-translations.yml b/.github/workflows/jh-translations.yml index 1e0f14e276f817..3050fe2e7d6752 100644 --- a/.github/workflows/jh-translations.yml +++ b/.github/workflows/jh-translations.yml @@ -22,7 +22,7 @@ jobs: runs-on: ${{ vars.RUNNER }} steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: Set up Python ${{ env.DEFAULT_PYTHON }} uses: actions/setup-python@v5.0.0 diff --git a/.github/workflows/jh-wheels.yml b/.github/workflows/jh-wheels.yml index 90d60b96c69437..21157931f4f491 100644 --- a/.github/workflows/jh-wheels.yml +++ b/.github/workflows/jh-wheels.yml @@ -30,7 +30,7 @@ jobs: architectures: ${{ steps.info.outputs.architectures }} steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: Get information id: info @@ -65,16 +65,18 @@ jobs: ) > .env_file - name: Upload env_file - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4.3.1 with: name: env_file path: ./.env_file + overwrite: true - name: Upload requirements_diff - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4.3.1 with: name: requirements_diff path: ./requirements_diff.txt + overwrite: true core: name: Build Core wheels ${{ matrix.abi }} for ${{ matrix.arch }} (musllinux_1_2) @@ -84,19 +86,19 @@ jobs: strategy: fail-fast: false matrix: - abi: ["cp311", "cp312"] + abi: ["cp312"] arch: ${{ fromJson(needs.init.outputs.architectures) }} steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: Download env_file - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.4 with: name: env_file - name: Download requirements_diff - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.4 with: name: requirements_diff @@ -122,19 +124,19 @@ jobs: strategy: fail-fast: false matrix: - abi: ["cp311", "cp312"] + abi: ["cp312"] arch: ${{ fromJson(needs.init.outputs.architectures) }} steps: - name: Checkout the repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4.1.2 - name: Download env_file - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.4 with: name: env_file - name: Download requirements_diff - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.4 with: name: requirements_diff diff --git a/build-jethub.yaml b/build-jethub.yaml index 1469bb61d9decf..33b40a96911cc5 100644 --- a/build-jethub.yaml +++ b/build-jethub.yaml @@ -1,10 +1,10 @@ image: ghcr.io/jethub-homeassistant/{arch}-homeassistant build_from: - aarch64: ghcr.io/jethub-homeassistant/aarch64-homeassistant-base:2024.02.0 - armhf: ghcr.io/jethub-homeassistant/armhf-homeassistant-base:2024.02.0 - armv7: ghcr.io/jethub-homeassistant/armv7-homeassistant-base:2024.02.0 - amd64: ghcr.io/jethub-homeassistant/amd64-homeassistant-base:2024.02.0 - i386: ghcr.io/jethub-homeassistant/i386-homeassistant-base:2024.02.0 + aarch64: ghcr.io/jethub-homeassistant/aarch64-homeassistant-base:2024.03.0 + armhf: ghcr.io/jethub-homeassistant/armhf-homeassistant-base:2024.03.0 + armv7: ghcr.io/jethub-homeassistant/armv7-homeassistant-base:2024.03.0 + amd64: ghcr.io/jethub-homeassistant/amd64-homeassistant-base:2024.03.0 + i386: ghcr.io/jethub-homeassistant/i386-homeassistant-base:2024.03.0 codenotary: signer: vb@jethome.ru base_image: vb@jethome.ru