Skip to content

Commit fb28256

Browse files
build: build multiplatform
1 parent 24fad15 commit fb28256

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

.github/workflows/go.yml

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,59 @@
1-
# This workflow will build a golang project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3-
4-
name: Go
1+
name: Go CI/CD
52

63
on:
74
push:
85
branches: [ "main" ]
6+
tags: [ "v*.*.*" ]
97
pull_request:
108
branches: [ "main" ]
119

1210
jobs:
13-
1411
build:
15-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
goos: linux
18+
ext: ""
19+
- os: windows-latest
20+
goos: windows
21+
ext: ".exe"
22+
- os: macos-latest
23+
goos: darwin
24+
ext: ""
1625
steps:
17-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-go@v4
29+
with:
30+
go-version: '1.23.0'
1831

19-
- name: Set up Go
20-
uses: actions/setup-go@v4
21-
with:
22-
go-version: '1.23.0'
32+
- run: |
33+
mkdir -p bin
34+
GOOS=${{ matrix.goos }} GOARCH=amd64 go build -v \
35+
-ldflags "-s -w" \
36+
-o bin/terminalapp_${{ matrix.goos }}_amd64${{ matrix.ext }} \
37+
./cmd/terminalapp/main
2338
24-
- name: Build
25-
run: go build -v ./cmd/terminalapp/main/...
39+
- uses: actions/upload-artifact@v3
40+
with:
41+
name: terminalapp-${{ matrix.goos }}-amd64
42+
path: bin/terminalapp_${{ matrix.goos }}_amd64${{ matrix.ext }}
43+
44+
release:
45+
needs: build
46+
runs-on: ubuntu-latest
47+
if: startsWith(github.ref, 'refs/tags/')
48+
steps:
49+
- uses: actions/download-artifact@v3
50+
with:
51+
path: ./bin
2652

27-
- name: Test the lib
28-
run: go test -v ./pkg/minesweeperlib
53+
- uses: softprops/action-gh-release@v1
54+
with:
55+
tag_name: ${{ github.ref_name }}
56+
name: Release ${{ github.ref_name }}
57+
files: ./bin/*
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)