.github/workflows/build_container.yml #369
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
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 --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 --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-arm64/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-arm64/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 }} |