forked from tonistiigi/binfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (147 loc) · 5.77 KB
/
release.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
141
142
143
144
145
146
147
148
149
150
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: tonistiigi/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 DockerHub
uses: docker/login-action@v3
if: github.event.inputs.dry-run != 'true'
with:
username: $
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 }}