File tree Expand file tree Collapse file tree 1 file changed +46
-15
lines changed
Expand file tree Collapse file tree 1 file changed +46
-15
lines changed Original file line number Diff line number Diff line change 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
63on :
74 push :
85 branches : [ "main" ]
6+ tags : [ "v*.*.*" ]
97 pull_request :
108 branches : [ "main" ]
119
1210jobs :
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 }}
You can’t perform that action at this time.
0 commit comments