Skip to content

release

release #9

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
qemu_repo:
description: 'QEMU source git repo'
required: false
qemu_ref:
description: 'QEMU git ref (ie. tag, branch or sha)'
required: false
qemu_version:
description: 'QEMU version (e.g. v5.2.0)'
required: true
target:
description: 'Bake target'
required: true
default: 'mainline'
latest:
description: 'Create latest tag'
required: true
default: 'false'
dry-run:
description: 'Dry run'
required: false
default: 'true'
env:
REPO_SLUG: ghcr.io/karellen/binfmt
CACHE_GHA_SCOPE_CROSS: binfmt-cross
jobs:
release:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Prepare
id: prep
run: |
REPO=$(docker buildx bake --print ${{ github.event.inputs.target }} | jq --raw-output '.. | .args?.QEMU_REPO | select(.)')
if [ "${{ github.event.inputs.qemu_repo }}" != "" ]; then
REPO=${{ github.event.inputs.qemu_repo }}
fi
REF=$(docker buildx bake --print ${{ github.event.inputs.target }} | jq --raw-output '.. | .args?.QEMU_VERSION | select(.)')
if [ "${{ github.event.inputs.qemu_ref }}" != "" ]; then
REF=${{ github.event.inputs.qemu_ref }}
fi
if [ "${{ github.event.inputs.target }}" = "mainline" ]; then
TAG_PREFIX=qemu-
GIT_TAG=deploy/${{ github.event.inputs.qemu_version }}-${{ github.run_number }}
else
TAG_PREFIX=${{ github.event.inputs.target }}-
GIT_TAG=${{ github.event.inputs.target }}/${{ github.event.inputs.qemu_version }}-${{ github.run_number }}
fi
echo repo=${REPO} >> $GITHUB_OUTPUT
echo ref=${REF} >> $GITHUB_OUTPUT
echo tag_prefix=${TAG_PREFIX} >> $GITHUB_OUTPUT
echo git_tag=${GIT_TAG} >> $GITHUB_OUTPUT
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REPO_SLUG }}
tags: |
type=raw,value=${{ steps.prep.outputs.tag_prefix }}${{ github.event.inputs.qemu_version }}-${{ github.run_number }}
type=raw,value=${{ steps.prep.outputs.tag_prefix }}${{ github.event.inputs.qemu_version }}
type=raw,value=${{ steps.prep.outputs.tag_prefix }}latest,enable=${{ github.event.inputs.target != 'mainline' && github.event.inputs.latest == 'true' }}
type=raw,value=latest,enable=${{ github.event.inputs.target == 'mainline' && github.event.inputs.latest == 'true' }}
flavor: |
latest=false
labels: |
org.opencontainers.image.title=Binfmt
org.opencontainers.image.description=Cross-platform emulator collection distributed with Docker images
bake-target: meta-helper
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:master
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GHCR
uses: docker/login-action@v3
if: github.event.inputs.dry-run != 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build image
uses: docker/bake-action@v5
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: ${{ github.event.inputs.target }}-all
push: ${{ github.event.inputs.dry-run != 'true' }}
set: |
*.cache-from=${{ env.REPO_SLUG }}:${{ steps.prep.outputs.tag_prefix }}${{ github.event.inputs.qemu_version }},${{ env.REPO_SLUG }}:${{ steps.prep.outputs.tag_prefix }}master
*.cache-from=type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}-${{ github.event.inputs.target }}
env:
REPO: ${{ env.REPO_SLUG }}
QEMU_REPO: ${{ steps.prep.outputs.repo }}
QEMU_VERSION: ${{ steps.prep.outputs.ref }}
-
name: Build artifacts
uses: docker/bake-action@v5
if: github.event.inputs.target == 'mainline'
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: archive-all
set: |
*.cache-from=${{ env.REPO_SLUG }}:${{ steps.prep.outputs.tag_prefix }}${{ github.event.inputs.qemu_version }},${{ env.REPO_SLUG }}:${{ steps.prep.outputs.tag_prefix }}master
*.cache-from=type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}-${{ github.event.inputs.target }}
*.output=type=local,dest=./bin,platform-split=false
env:
REPO: ${{ env.REPO_SLUG }}
QEMU_REPO: ${{ steps.prep.outputs.repo }}
QEMU_VERSION: ${{ steps.prep.outputs.ref }}
-
name: List artifacts
if: github.event.inputs.target == 'mainline'
run: |
tree -nh ./bin
-
name: Create Release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
if: github.event.inputs.dry-run != 'true'
with:
name: ${{ steps.prep.outputs.git_tag }}
tag_name: ${{ steps.prep.outputs.git_tag }}
prerelease: ${{ github.event.inputs.latest != 'true' }}
files: bin/*.tar.gz
fail_on_unmatched_files: false
target_commitish: ${{ github.sha }}
body: |
* logs: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}
* qemu repo: ${{ steps.prep.outputs.repo }}/tree/${{ steps.prep.outputs.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}