Skip to content

use snapshot

use snapshot #357

on:
push:
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 || 'latest' || 'latest' }} .
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 || 'latest' || 'latest' }} .
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 || 'latest' || 'latest' }}
podman inspect ghcr.io/${{ github.repository }}/host-${{ matrix.host }}/target-${{ matrix.target }}:${{ inputs.version || 'latest' || 'latest' }}
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 || 'latest' }}
podman manifest add --arch amd64 ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version || 'latest' }} ghcr.io/${{ github.repository }}/host-amd64/target-amd64:${{ inputs.version || 'latest' }}
podman manifest add --arch arm64 ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version || 'latest' }} ghcr.io/${{ github.repository }}/host-arm64/target-amd64:${{ inputs.version || 'latest' }}
podman push ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version || 'latest' }}
podman manifest inspect ghcr.io/${{ github.repository }}/target-amd64:${{ inputs.version || 'latest' }}
podman manifest create ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version || 'latest' }}
podman manifest add --arch amd64 ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version || 'latest' }} ghcr.io/${{ github.repository }}/host-amd64/target-arm64v8:${{ inputs.version || 'latest' }}
podman manifest add --arch arm64 ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version || 'latest' }} ghcr.io/${{ github.repository }}/host-arm64/target-arm64v8:${{ inputs.version || 'latest' }}
podman push ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version || 'latest' }}
podman manifest inspect ghcr.io/${{ github.repository }}/target-arm64v8:${{ inputs.version || 'latest' }}