Skip to content

Commit

Permalink
organize code
Browse files Browse the repository at this point in the history
  • Loading branch information
airkei committed Jan 22, 2025
1 parent b25b277 commit 8b0349c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 40 deletions.
44 changes: 44 additions & 0 deletions .github/actions/build_squashfs_image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Build SquashFS Image"
description: "Builds a SquashFS image using Docker"
inputs:
platform:
description: "The platform to build for"
required: true
platform_suffix:
description: "The platform suffix"
required: true
runs:
using: "composite"
steps:
- name: checkout
uses: actions/checkout@v4

- name: build docker image
shell: bash
run: |
cp ${{ env.OTACLIENT_WHL }} docker/app_img/
pushd docker/app_img
docker buildx create --name builder_${{ inputs.platform_suffix }}
docker buildx build --platform ${{ inputs.platform }} \
--build-arg=OTACLIENT_VERSION=${{ env.OTACLIENT_VERSION }} \
--build-arg=OTACLIENT_WHL=${{ env.OTACLIENT_WHL }} \
-t ${{ env.DOCKER_IMAGE }} \
--output type=docker \
.
popd
rm docker/app_img/${{ env.OTACLIENT_WHL }}
- name: export squashfs image
shell: bash
run: |
docker create --name ${{ env.DOCKER_CONTAINER }} ${{ env.DOCKER_IMAGE }}
docker export ${{ env.DOCKER_CONTAINER }} | mksquashfs - ${{ env.SQUASHFS }} \
-tar -b 1M \
-mkfs-time 1729810800 \
-all-time 1729810800 \
-no-xattrs \
-all-root \
-progress \
-comp zstd \
-Xcompression-level 22
mv ${{ env.SQUASHFS }} dist/
57 changes: 17 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,63 +46,40 @@ jobs:
popd
cp proto/dist/*.whl dist/
# common job to build squashfs images for x86_64 and arm64
build_squashfs_image:
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 }}
PLATFORM: ${{ inputs.platform }}
PLATFORM_SUFFIX: ${{ inputs.platform_suffix }}
DOCKER_IMAGE: otaclient-${PLATFORM_SUFFIX}:${OTACLIENT_VERSION}
DOCKER_CONTAINER: otaclient-${PLATFORM_SUFFIX}_v${OTACLIENT_VERSION}
SQUASHFS: otaclient-${PLATFORM_SUFFIX}_v${OTACLIENT_VERSION}.squashfs
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: build docker image
run: |
cp dist/${OTACLIENT_WHL} docker/app_img/
pushd docker/app_img
docker buildx create --name builder_${PLATFORM_SUFFIX}
docker buildx build --platform ${PLATFORM} \
--build-arg=OTACLIENT_VERSION=${OTACLIENT_VERSION} \
--build-arg=OTACLIENT_WHL=${OTACLIENT_WHL} \
-t ${DOCKER_IMAGE} \
--output type=docker \
.
popd
rm docker/app_img/${OTACLIENT_WHL}
- name: export squashfs image
run: |
docker create --name ${DOCKER_CONTAINER} ${DOCKER_IMAGE}
docker export ${DOCKER_CONTAINER} | mksquashfs - ${SQUASHFS} \
-tar -b 1M \
-mkfs-time 1729810800 \
-all-time 1729810800 \
-no-xattrs \
-all-root \
-progress \
-comp zstd \
-Xcompression-level 22
mv ${SQUASHFS} dist/
- name: checkout
uses: actions/checkout@v4

build_squashfs_image_x86_64:
runs-on: ubuntu-latest
needs: build_packages
steps:
- name: export squashfs image for x86_64
uses: ./.github/workflows/release.yml@build_squashfs_image
uses: ./.github/actions/build_squashfs_image
with:
platform: linux/amd64
platform_suffix: x86_64

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: export squashfs image for arm64
uses: ./.github/workflows/release.yml@build_squashfs_image
uses: ./.github/actions/build_squashfs_image
with:
platform: linux/arm64
platform_suffix: arm64
Expand Down

0 comments on commit 8b0349c

Please sign in to comment.