Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 6fec3da

Browse files
committed
chore: use build matrix for workflow
1 parent 98d2790 commit 6fec3da

File tree

1 file changed

+13
-83
lines changed

1 file changed

+13
-83
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ on:
1111
- main
1212

1313
jobs:
14-
build_linux:
14+
build:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
goos: [linux, windows, darwin]
19+
goarch: [amd64, arm64]
1620
steps:
1721
- uses: actions/checkout@v2
1822
- name: setup golang
@@ -21,98 +25,24 @@ jobs:
2125
go-version: 1.17
2226
- name: build project
2327
env:
24-
GOOS: "linux"
25-
GOARCH: "amd64"
26-
run: go build -o build/monstercat_linux_amd64 main.go
28+
GOOS: ${{ matrix.goos }}
29+
GOARCH: ${{ matrix.goarch }}
30+
run: go build -o build/monstercat_${{ matrix.goos }}_${{ matrix.goarch }} main.go
2731
- name: store binary
2832
uses: actions/upload-artifact@v2
2933
with:
30-
name: linux
31-
path: build/
32-
build_windows:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v2
36-
- name: setup golang
37-
uses: actions/setup-go@v2
38-
with:
39-
go-version: 1.17
40-
- name: build project
41-
env:
42-
GOOS: "windows"
43-
GOARCH: "amd64"
44-
run: go build -o build/monstercat_windows_amd64.exe main.go
45-
- name: store binary
46-
uses: actions/upload-artifact@v2
47-
with:
48-
name: windows
49-
path: build/
50-
build_darwin_amd64:
51-
runs-on: ubuntu-latest
52-
steps:
53-
- uses: actions/checkout@v2
54-
- name: setup golang
55-
uses: actions/setup-go@v2
56-
with:
57-
go-version: 1.17
58-
- name: build project
59-
env:
60-
GOOS: "darwin"
61-
GOARCH: "amd64"
62-
run: go build -o build/monstercat_darwin_amd64 main.go
63-
- name: store binary
64-
uses: actions/upload-artifact@v2
65-
with:
66-
name: darwin_amd64
67-
path: build/
68-
build_darwin_arm64:
69-
runs-on: ubuntu-latest
70-
steps:
71-
- uses: actions/checkout@v2
72-
- name: setup golang
73-
uses: actions/setup-go@v2
74-
with:
75-
go-version: 1.17
76-
- name: build project
77-
env:
78-
GOOS: "darwin"
79-
GOARCH: "arm64"
80-
run: go build -o build/monstercat_darwin_arm64 main.go
81-
- name: store binary
82-
uses: actions/upload-artifact@v2
83-
with:
84-
name: darwin_arm64
34+
name: ${{ matrix.goos }}_${{ matrix.goarch }}
8535
path: build/
8636
release:
8737
runs-on: ubuntu-latest
88-
needs: [build_linux, build_windows, build_darwin_amd64, build_darwin_arm64]
38+
needs: [build]
8939
if: startsWith(github.ref, 'refs/tags/')
9040
steps:
91-
- name: download linux binary
92-
uses: actions/download-artifact@v2
93-
with:
94-
name: linux
95-
path: linux/
96-
- name: download windows binary
41+
- name: download all binaries
9742
uses: actions/download-artifact@v2
9843
with:
99-
name: windows
100-
path: windows/
101-
- name: download darwin amd64 binary
102-
uses: actions/download-artifact@v2
103-
with:
104-
name: darwin_amd64
105-
path: darwin_amd64/
106-
- name: download darwin arm64 binary
107-
uses: actions/download-artifact@v2
108-
with:
109-
name: darwin_arm64
110-
path: darwin_arm64/
44+
path: build/
11145
- name: upload artifacts to release
11246
uses: softprops/action-gh-release@v1
11347
with:
114-
files: |
115-
linux/monstercat_linux_amd64
116-
windows/monstercat_windows_amd64.exe
117-
darwin_amd64/monstercat_darwin_amd64
118-
darwin_arm64/monstercat_darwin_arm64
48+
files: build/*

0 commit comments

Comments
 (0)