-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (137 loc) · 5.49 KB
/
binfmt.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: buildx-binfmt
on:
workflow_dispatch:
inputs:
qemu_version:
description: 'QEMU version (e.g. v5.2.0)'
required: true
default: 'v8.1.5'
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/loong64/binfmt
CACHE_GHA_SCOPE_CROSS: binfmt-cross
jobs:
release:
runs-on: ubuntu-24.04
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
repository: loong64/binfmt
ref: patch_loong64
-
name: Prepare
id: prep
run: |
REPO=$(docker buildx bake --print ${{ github.event.inputs.target }} | jq --raw-output '.. | .args?.QEMU_REPO | select(.)')
REF=$(docker buildx bake --print ${{ github.event.inputs.target }} | jq --raw-output '.. | .args?.QEMU_VERSION | select(.)')
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
run: |
docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
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 }}
BUILDPLATFORM: linux/loong64
-
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 }}
BUILDPLATFORM: linux/loong64
-
name: List artifacts
if: github.event.inputs.target == 'mainline'
run: |
tree -nh ./bin
-
name: Create Release
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
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.GH_TOKEN }}