Skip to content

release

release #3

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: karellen/binfmt
CACHE_GHA_SCOPE_CROSS: binfmt-cross
jobs:
release:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
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 ::set-output name=repo::${REPO}
echo ::set-output name=ref::${REF}
echo ::set-output name=tag_prefix::${TAG_PREFIX}
echo ::set-output name=git_tag::${GIT_TAG}
-
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: ${{ env.REPO_SLUG }}: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 }}