9
9
10
10
jobs :
11
11
build :
12
- runs-on : ubuntu-latest
12
+ runs-on : ${{ matrix.os }}
13
+ strategy :
14
+ max-parallel : 3
15
+ matrix :
16
+ os : [ubuntu-latest]
17
+ system : [linux]
18
+ arch : [amd64, arm, arm64]
19
+ # support windows build and push?
20
+ # see the issue: https://github.com/docker/build-push-action/issues/18
21
+ # include:
22
+ # - os: windows-2022
23
+ # system: windows
24
+ # arch: amd64
13
25
steps :
14
26
- name : Setup go
15
27
uses : actions/setup-go@v3
@@ -22,17 +34,17 @@ jobs:
22
34
23
35
- name : Build binary
24
36
run : |
25
- make build_linux_amd64
26
- make build_linux_arm64
27
- make build_linux_arm
37
+ make build_${{ matrix.system }}_${{ matrix.arch }}
28
38
29
39
- name : Check binary
40
+ if : matrix.system == 'linux' && matrix.arch == 'amd64'
30
41
run : |
31
- ./release/linux/amd64/drone-ssh --help
42
+ ./release/${{ matrix.system }}/${{ matrix.arch }}/${GITHUB_REPOSITORY#*/} --help
32
43
33
44
-
34
45
name : Set up QEMU
35
46
uses : docker/setup-qemu-action@v2
47
+
36
48
-
37
49
name : Set up Docker Buildx
38
50
uses : docker/setup-buildx-action@v2
@@ -53,86 +65,30 @@ jobs:
53
65
password : ${{ secrets.GITHUB_TOKEN }}
54
66
55
67
-
56
- name : Docker meta for linux amd64
57
- id : meta-linux-amd64
68
+ name : Docker meta for ${{ matrix.system }} ${{ matrix.arch }}
69
+ id : docker-meta
58
70
uses : docker/metadata-action@v4
59
71
with :
60
72
flavor : |
61
73
latest=false
62
- suffix=linux-amd64
74
+ suffix=${{ matrix.system }}-${{ matrix.arch }}
63
75
images : |
64
- appleboy/drone-ssh
65
- ghcr.io/appleboy/drone-ssh
76
+ ${{ github.repository }}
77
+ ghcr.io/${{ github.repository }}
66
78
tags : |
67
79
type=raw,value=,enable={{is_default_branch}}
68
80
type=raw,value=latest,suffix=,enable={{is_default_branch}}
69
- type=semver,event=tag,pattern={{version}},suffix=-linux-amd64
70
- type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-amd64
71
- type=semver,event=tag,pattern={{major}},suffix=-linux-amd64
72
-
73
- -
74
- name : Build and push linux amd64
75
- uses : docker/build-push-action@v3
76
- with :
77
- context : .
78
- file : docker/Dockerfile.linux.amd64
79
- platforms : linux/amd64
80
- push : true
81
- tags : ${{ steps.meta-linux-amd64.outputs.tags }}
82
- labels : ${{ steps.meta-linux-amd64.outputs.labels }}
83
-
84
- -
85
- name : Docker meta for linux arm64
86
- id : meta-linux-arm64
87
- uses : docker/metadata-action@v4
88
- with :
89
- flavor : |
90
- latest=false
91
- suffix=linux-arm64
92
- images : |
93
- appleboy/drone-ssh
94
- ghcr.io/appleboy/drone-ssh
95
- tags : |
96
- type=raw,value=,enable={{is_default_branch}}
97
- type=semver,event=tag,pattern={{version}},suffix=-linux-arm64
98
- type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm64
99
- type=semver,event=tag,pattern={{major}},suffix=-linux-arm64
100
-
101
- -
102
- name : Build and push linux arm64
103
- uses : docker/build-push-action@v3
104
- with :
105
- context : .
106
- file : docker/Dockerfile.linux.arm64
107
- platforms : linux/arm64
108
- push : true
109
- tags : ${{ steps.meta-linux-arm64.outputs.tags }}
110
- labels : ${{ steps.meta-linux-arm64.outputs.labels }}
111
-
112
- -
113
- name : Docker meta for linux arm
114
- id : meta-linux-arm
115
- uses : docker/metadata-action@v4
116
- with :
117
- flavor : |
118
- latest=false
119
- suffix=linux-arm
120
- images : |
121
- appleboy/drone-ssh
122
- ghcr.io/appleboy/drone-ssh
123
- tags : |
124
- type=raw,value=,enable={{is_default_branch}}
125
- type=semver,event=tag,pattern={{version}},suffix=-linux-arm
126
- type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm
127
- type=semver,event=tag,pattern={{major}},suffix=-linux-arm
81
+ type=semver,event=tag,pattern={{version}},suffix=-${{ matrix.system }}-${{ matrix.arch }}
82
+ type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-${{ matrix.system }}-${{ matrix.arch }}
83
+ type=semver,event=tag,pattern={{major}},suffix=-${{ matrix.system }}-${{ matrix.arch }}
128
84
129
85
-
130
- name : Build and push linux arm
86
+ name : Build and push ${{ matrix.system }} ${{ matrix.arch }}
131
87
uses : docker/build-push-action@v3
132
88
with :
133
89
context : .
134
- file : docker/Dockerfile.linux.arm
135
- platforms : linux/arm
90
+ file : docker/Dockerfile.${{ matrix.system }}.${{ matrix.arch }}
91
+ platforms : ${{ matrix.system }}/${{ matrix.arch }}
136
92
push : true
137
- tags : ${{ steps.meta-linux-arm .outputs.tags }}
138
- labels : ${{ steps.meta-linux-arm .outputs.labels }}
93
+ tags : ${{ steps.docker-meta .outputs.tags }}
94
+ labels : ${{ steps.docker-meta .outputs.labels }}
0 commit comments