@@ -9,48 +9,40 @@ permissions:
99 contents : write
1010
1111jobs :
12- build-and-release :
13- runs-on : ubuntu-latest
12+ build :
13+ runs-on : ${{ matrix.os }}
1414 strategy :
1515 matrix :
1616 go-version : ["1.20"]
17+ os : [ubuntu-latest, macos-latest, windows-latest]
1718
1819 steps :
19- # Checkout repo
2020 - name : Checkout code
2121 uses : actions/checkout@v4
2222
23- # Set up Go
24- - name : Set up Go ${{ matrix.go-version }}
23+ - name : Set up Go
2524 uses : actions/setup-go@v5
2625 with :
2726 go-version : ${{ matrix.go-version }}
2827
29- # Create release directory
3028 - name : Create release dir
3129 run : mkdir -p release
3230
33- # Build Linux binary
34- - name : Build Linux
35- run : GOOS=linux GOARCH=amd64 go build -o release/gores-linux-amd64 main.go
36-
37- # Build macOS binary
38- - name : Build macOS
39- run : GOOS=darwin GOARCH=amd64 go build -o release/gores-darwin-amd64 main.go
40-
41- # Build Windows binary
42- - name : Build Windows
43- run : GOOS=windows GOARCH=amd64 go build -o release/gores-windows-amd64.exe main.go
44-
45- # Create GitHub Release
46- - name : Create Release
47- uses : softprops/action-gh-release@v1
31+ - name : Build binary
32+ run : |
33+ if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
34+ GOOS=linux GOARCH=amd64 go build -o release/gores-linux-amd64 main.go
35+ elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
36+ GOOS=darwin GOARCH=amd64 go build -o release/gores-darwin-amd64 main.go
37+ else
38+ GOOS=windows GOARCH=amd64 go build -o release/gores-windows-amd64.exe main.go
39+ fi
40+
41+ - name : Upload artifact
42+ uses : actions/upload-artifact@v4
4843 with :
49- tag_name : ${{ github.ref_name }}
50- files : |
51- release/gores-linux-amd64
52- release/gores-darwin-amd64
53- release/gores-windows-amd64.exe
44+ name : ${{ matrix.os }}-binary
45+ path : release/*
5446
5547 release :
5648 if : startsWith(github.ref, 'refs/tags/v')
8274 with :
8375 tag_name : ${{ github.ref_name }}
8476 name : 🚀 Go Microservice Boilerplate ${{ github.ref_name }}
77+ files : |
78+ release/gores-linux-amd64
79+ release/gores-darwin-amd64
80+ release/gores-windows-amd64.exe
8581 body : |
8682 ## 📦 Go Microservice Boilerplate — ${{ github.ref_name }}
8783
9187 - **Linux (x86_64)** → [gores-linux-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-linux-amd64)
9288 - **macOS (x86_64)** → [gores-darwin-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-darwin-amd64)
9389 - **Windows (x86_64)** → [gores-windows-amd64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-windows-amd64.exe)
94-
90+
9591 #### Linux / macOS
9692 ```bash
9793 curl -L -o gores https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-linux-amd64
@@ -138,35 +134,5 @@ jobs:
138134
139135 ---
140136 _Built automatically via GitHub Actions._
141- env :
142- GITHUB_TOKEN : ${{ secrets.MY_PAT }}
143-
144- - name : Upload Linux binary
145- uses : softprops/action-gh-release@v1
146- with :
147- tag_name : ${{ github.ref_name }}
148- asset_path : release/gores
149- asset_name : gores-linux-amd64
150- asset_content_type : application/octet-stream
151- env :
152- GITHUB_TOKEN : ${{ secrets.MY_PAT }}
153-
154- - name : Upload macOS binary
155- uses : softprops/action-gh-release@v1
156- with :
157- tag_name : ${{ github.ref_name }}
158- asset_path : release/gores
159- asset_name : gores-darwin-amd64
160- asset_content_type : application/octet-stream
161- env :
162- GITHUB_TOKEN : ${{ secrets.MY_PAT }}
163-
164- - name : Upload Windows binary
165- uses : softprops/action-gh-release@v1
166- with :
167- tag_name : ${{ github.ref_name }}
168- asset_path : release/gores.exe
169- asset_name : gores-windows-amd64.exe
170- asset_content_type : application/octet-stream
171137 env :
172138 GITHUB_TOKEN : ${{ secrets.MY_PAT }}
0 commit comments