ci: add squashfs build jobs #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release CI | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
- reopened | |
# NOTE(20241016): this is a workaround for PR with head | |
# updated by gen_requirements_txt workflow | |
- review_requested | |
- assigned | |
# allow manually triggering the build | |
workflow_dispatch: | |
jobs: | |
build_packages: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
OTACLIENT_WHL: ${{ steps.set_env.outputs.OTACLIENT_WHL }} | |
OTACLIENT_VERSION: ${{ steps.set_env.outputs.OTACLIENT_VERSION }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
# use the minimum py ver we support to generate the wheel | |
python-version: 3.8 | |
- name: install build deps | |
run: | | |
python -m pip install -U pip | |
python -m pip install -U hatch | |
- name: build otaclient package | |
run: | | |
hatch build -t wheel | |
- name: set environment variables | |
id: set_env | |
run: | | |
OTACLIENT_WHL=$(basename $(ls dist/otaclient-*.whl)) | |
OTACLIENT_VERSION=$(echo $OTACLIENT_WHL | sed -E 's/otaclient-([0-9]+\.[0-9]+\.[0-9]+).*\.whl/\1/') | |
echo "::set-output name=OTACLIENT_WHL::${OTACLIENT_WHL}" | |
echo "::set-output name=OTACLIENT_VERSION::${OTACLIENT_VERSION}" | |
- name: build otaclient service API python package | |
run: | | |
pushd proto | |
hatch build -t wheel | |
popd | |
cp proto/dist/*.whl dist/ | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-directory | |
path: dist/*.whl | |
build_squashfs_image_x86_64: | |
runs-on: ubuntu-latest | |
needs: build_packages | |
env: | |
OTACLIENT_WHL: ${{ needs.build_packages.outputs.OTACLIENT_WHL }} | |
OTACLIENT_VERSION: ${{ needs.build_packages.outputs.OTACLIENT_VERSION }} | |
DOCKER_IMAGE: otaclient-x86_64:${{ needs.build_packages.outputs.OTACLIENT_VERSION }} | |
DOCKER_CONTAINER: otaclient-x86_64_v${{ needs.build_packages.outputs.OTACLIENT_VERSION }} | |
SQUASHFS: otaclient-x86_64_v${{ needs.build_packages.outputs.OTACLIENT_VERSION }}.squashfs | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: build squashfs image for x86_64 | |
uses: ./.github/actions/build_squashfs_image | |
with: | |
platform: linux/amd64 | |
platform_suffix: x86_64 | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.squashfs | |
build_squashfs_image_arm64: | |
runs-on: ubuntu-latest | |
needs: build_packages | |
env: | |
OTACLIENT_WHL: ${{ needs.build_packages.outputs.OTACLIENT_WHL }} | |
OTACLIENT_VERSION: ${{ needs.build_packages.outputs.OTACLIENT_VERSION }} | |
DOCKER_IMAGE: otaclient-arm64:${{ needs.build_packages.outputs.OTACLIENT_VERSION }} | |
DOCKER_CONTAINER: otaclient-arm64_v${{ needs.build_packages.outputs.OTACLIENT_VERSION }} | |
SQUASHFS: otaclient-arm64_v${{ needs.build_packages.outputs.OTACLIENT_VERSION }}.squashfs | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: build squashfs image for arm64 | |
uses: ./.github/actions/build_squashfs_image | |
with: | |
platform: linux/arm64 | |
platform_suffix: arm64 | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.squashfs | |
calculate_checksum: | |
runs-on: ubuntu-latest | |
needs: [build_squashfs_image_x86_64, build_squashfs_image_arm64] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: calculate checksum | |
run: | | |
for WHL in dist/*.whl; \ | |
do \ | |
sha256sum ${WHL} | sed -E "s@(\w+)\s+.*@sha256:\1@" > \ | |
${WHL}.checksum; \ | |
done | |
for SQUASHFS in dist/*.squashfs; \ | |
do \ | |
sha256sum ${SQUASHFS} | sed -E "s@(\w+)\s+.*@sha256:\1@" > \ | |
${SQUASHFS}.checksum; \ | |
done | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.checksum | |
publish_release_artifacts: | |
runs-on: ubuntu-latest | |
needs: calculate_checksum | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: debug | |
run: | | |
ls -l dist |