-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (59 loc) · 3.29 KB
/
build_container.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
on:
workflow_dispatch:
inputs:
version:
type: string
default: latest
publish:
type: boolean
default: false
jobs:
build:
name: build (host=${{ matrix.host }}, target=${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
host: [ amd64, arm64v8 ]
target: [ amd64, arm64v8 ]
steps:
- uses: actions/checkout@v3
- name: setup binfmt
run: sudo podman run --privileged -v /proc/sys/fs/binfmt_misc:/proc/sys/fs/binfmt_misc "ghcr.io/gardenlinux/binfmt_container"
- name: build
run: |
set -x
cd container
if [ ${{ matrix.host }} = ${{ matrix.target }} ]; then
podman build --squash-all --build-arg arch=${{ matrix.host }} -f build.containerfile -t ghcr.io/${{ github.repository }}/host-${{ matrix.host }}/target-${{ matrix.target }}:${{ inputs.version }} .
else
case ${{ matrix.target }} in
amd64) gnu_arch=x86-64 ;;
arm64v8) gnu_arch=aarch64 ;;
esac
podman build --squash-all --build-arg native_arch=${{ matrix.host }} --build-arg target_arch=${{ matrix.target }} --build-arg gnu_arch=$gnu_arch -f crossbuild.containerfile -t ghcr.io/${{ github.repository }}/host-${{ matrix.host }}/target-${{ matrix.target }}:${{ inputs.version }} .
fi
- name: publish
if: ${{ inputs.publish }}
run: |
podman login -u token -p ${{ github.token }} ghcr.io
podman push ghcr.io/${{ github.repository }}/host-${{ matrix.host }}/target-${{ matrix.target }}:${{ inputs.version }}
podman inspect ghcr.io/${{ github.repository }}/host-${{ matrix.host }}/target-${{ matrix.target }}:${{ inputs.version }}
publish:
runs-on: ubuntu-latest
needs: build
if: ${{ inputs.publish }}
steps:
- name: publish
run: |
podman login -u token -p ${{ github.token }} ghcr.io
podman manifest create ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version }}
podman manifest add --arch amd64 ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version }} ghcr.io/${{ github.repository }}/host-amd64/target-amd64:${{ inputs.version }}
podman manifest add --arch arm64 ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version }} ghcr.io/${{ github.repository }}/host-arm64v8/target-amd64:${{ inputs.version }}
podman push ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version }}
podman manifest inspect ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version }}
podman manifest create ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version }}
podman manifest add --arch amd64 ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version }} ghcr.io/${{ github.repository }}/host-amd64/target-arm64v8:${{ inputs.version }}
podman manifest add --arch arm64 ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version }} ghcr.io/${{ github.repository }}/host-arm64v8/target-arm64v8:${{ inputs.version }}
podman push ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version }}
podman manifest inspect ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version }}