-
Notifications
You must be signed in to change notification settings - Fork 71
146 lines (143 loc) · 5.68 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
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
steps:
-
name: Checkout
uses: actions/checkout@v3
-
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@v4
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@v2
with:
image: ${{ env.REPO_SLUG }}:master
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
if: github.event.inputs.dry-run != 'true'
with:
username: ${{ secrets.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_PASSWORD }}
-
name: Build image
uses: docker/bake-action@v2
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@v2
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 }}
env:
REPO: ${{ env.REPO_SLUG }}
QEMU_REPO: ${{ steps.prep.outputs.repo }}
QEMU_VERSION: ${{ steps.prep.outputs.ref }}
-
name: Move artifacts
if: github.event.inputs.target == 'mainline'
run: |
mv ./bin/**/* ./bin/
-
name: Create Release
uses: softprops/action-gh-release@9729932bfb75c05ad1f6e3a729294e05abaa7001
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 }}