forked from crazy-max/xgo
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (175 loc) · 4.66 KB
/
images.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: images
on:
push:
branches:
- 'master'
tags:
- 'v*'
paths-ignore:
- '**.md'
pull_request:
branches:
- 'master'
paths-ignore:
- '**.md'
env:
DOCKERHUB_SLUG: crazymax/xgo
GHCR_SLUG: ghcr.io/crazy-max/xgo
jobs:
base:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.xgo-cache
key: ${{ runner.os }}-xgo-base-${{ github.sha }}
restore-keys: |
${{ runner.os }}-xgo-base-
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.DOCKERHUB_SLUG }}
${{ env.GHCR_SLUG }}
tags: |
base
labels: |
org.opencontainers.image.title=xgo
org.opencontainers.image.description=Go CGO cross compiler
org.opencontainers.image.vendor=CrazyMax
-
name: Login to DockerHub
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GHCR
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build
uses: docker/bake-action@v1
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: base
set: |
*.cache-from=type=local,src=/tmp/.xgo-cache
*.cache-to=type=local,dest=/tmp/.xgo-cache-new
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
-
# FIXME: https://github.com/docker/build-push-action/issues/252
name: Move cache
run: |
rm -rf /tmp/.xgo-cache
mv /tmp/.xgo-cache-new /tmp/.xgo-cache
go:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [ base ]
env:
BASE_IMAGE: ghcr.io/crazy-max/xgo:base
LATEST_117: 1.17.5
LATEST_116: 1.16.12
strategy:
fail-fast: false
matrix:
go_version:
- 1.16.0
- 1.16.1
- 1.16.2
- 1.16.3
- 1.16.4
- 1.16.5
- 1.16.6
- 1.16.7
- 1.16.8
- 1.16.9
- 1.16.10
- 1.16.11
- 1.16.12
- 1.17.0
- 1.17.1
- 1.17.2
- 1.17.3
- 1.17.4
- 1.17.5
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Tags
id: tags
uses: actions/github-script@v5
with:
result-encoding: string
script: |
const os = require('os');
const tags = ["${{ matrix.go_version }}"];
switch ("${{ matrix.go_version }}") {
case "${{ env.LATEST_117 }}": {
tags.push("1.17.x", "1.17", "latest");
break;
}
case "${{ env.LATEST_116 }}": {
tags.push("1.16.x", "1.16");
break;
}
}
return tags.join(os.EOL);
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.DOCKERHUB_SLUG }}
${{ env.GHCR_SLUG }}
tags: ${{ steps.tags.outputs.result }}
labels: |
org.opencontainers.image.title=xgo (go-${{ matrix.go_version }})
org.opencontainers.image.description=Go CGO cross compiler
org.opencontainers.image.vendor=CrazyMax
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build
uses: docker/bake-action@v1
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: go-${{ matrix.go_version }}
push: true