From 78a3f70567ec3d3ac09f820fafcbcd806157369b Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 4 Nov 2023 15:11:42 +0100 Subject: [PATCH] .github: initial container builder Signed-off-by: Joachim Wiberg --- .github/workflows/build.yml | 92 +++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e88335b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +name: Container Claus + +on: + push: + branches: + - '**' + tags: + - '*' + workflow_dispatch: + +env: + IMAGE_NAME: curiOS + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + strategy: + matrix: + platform: [amd64, arm64] + steps: + - uses: actions/checkout@v4 + - name: Build Variables + id: vars + run: | + target=${{ matrix.platform }} + echo "dir=curios-$target" >> $GITHUB_OUTPUT + echo "tgz=curios-$target.tar.gz" >> $GITHUB_OUTPUT + - name: Restore Cache of dl/ + uses: actions/cache@v3 + with: + path: dl/ + key: dl-${{ matrix.platform }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }} + restore-keys: | + dl-${{ matrix.platform }}- + dl- + - name: Restore Cache of .ccache/ + uses: actions/cache@v3 + with: + path: .ccache/ + key: ccache-${{ matrix.platform }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }} + restore-keys: | + ccache-${{ matrix.platform }}- + ccache- + - name: Configure & Build + run: | + make curios_${{ matrix.platform }}_defconfig + make + - name: Prepare Artifact + run: | + cd output + mv images ${{ steps.vars.outputs.dir }} + ln -s ${{ steps.vars.outputs.dir }} images + tar chfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }} + - uses: actions/upload-artifact@v3 + with: + path: output/${{ steps.vars.outputs.tgz }} + + push: + if: ${{github.repository_owner == 'kernelkit' && github.ref_name == 'main'}} + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v3 + - name: Prepare Aritfacts + run: | + for file in curios-*.tgz; do + tar xf $file + done + mkdir rootfs-oci + cp curios-*/* rootfs-oci/ + jq -s '.[0].manifests=[.[].manifests|add]|.[0]' curios-*/index.json > rootfs-oci/index.json + ls -l rootfs-oci/ + cat rootfs-oci/index.json + - name: Log in to registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | skopeo login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + [ "$VERSION" == "main" ] && VERSION=edge + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + cd output/${{ steps.vars.outputs.dir }} + ls -l + skopeo copy oci:rootfs-oci:$VERSION docker://$IMAGE_ID:$VERSION