-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (155 loc) · 5.82 KB
/
release.yaml
File metadata and controls
190 lines (155 loc) · 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Release
on:
push:
tags:
- 'v*.*.*' # Trigger on version tags like vv1.0.0
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.20"]
steps:
# Checkout repo
- name: Checkout code
uses: actions/checkout@v4
# Set up Go
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
# Create release directory
- name: Create release dir
run: mkdir -p release
# Build Linux binary
- name: Build Linux
run: GOOS=linux GOARCH=amd64 go build -o release/gores-linux-amd64 main.go
# Build macOS binary
- name: Build macOS
run: GOOS=darwin GOARCH=amd64 go build -o release/gores-darwin-amd64 main.go
# Build Windows binary
- name: Build Windows
run: GOOS=windows GOARCH=amd64 go build -o release/gores-windows-amd64.exe main.go
# Create GitHub Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
files: |
release/gores-linux-amd64
release/gores-darwin-amd64
release/gores-windows-amd64.exe
- name: Upload Linux binary
uses: actions/upload-artifact@v4
with:
name: gores-linux-amd64
path: release/gores-linux-amd64
- name: Upload macOS binary
uses: actions/upload-artifact@v4
with:
name: gores-darwin-amd64
path: release/gores-darwin-amd64
- name: Upload Windows binary
uses: actions/upload-artifact@v4
with:
name: gores-windows-amd64.exe
path: release/gores-windows-amd64.exe
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build-and-release
runs-on: ubuntu-latest
steps:
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: ubuntu-latest-binary
path: release
- name: Download macOS artifact
uses: actions/download-artifact@v4
with:
name: macos-latest-binary
path: release
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: windows-latest-binary
path: release
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: 🚀 Go Microservice Boilerplate ${{ github.ref_name }}
body: |
## 📦 Go Microservice Boilerplate — ${{ github.ref_name }}
Precompiled binaries are available for **Linux**, **macOS**, and **Windows**.
### 🔽 1. Download Binaries
- **Linux (x86_64)** → [gores-linux-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-linux-amd64)
- **macOS (x86_64)** → [gores-darwin-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-darwin-amd64)
- **Windows (x86_64)** → [gores-windows-amd64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-windows-amd64.exe)
#### Linux / macOS
```bash
curl -L -o gores https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-linux-amd64
chmod +x gores
./gores
```
#### Windows (PowerShell)
```powershell
Invoke-WebRequest -Uri "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-windows-amd64.exe" -OutFile "gores.exe"
.\gores.exe
```
---
### 💻 2. Install via `go install` (Go 1.17+)
```bash
go install github.com/${{ github.repository }}@${{ github.ref_name }}
```
This will install the binary into your `$GOPATH/bin` or `$HOME/go/bin`.
---
### 📥 3. Install via `go get` (older Go versions)
```bash
go get github.com/${{ github.repository }}@${{ github.ref_name }}
```
---
### 🛠 4. Build from Source
```bash
git clone https://github.com/${{ github.repository }}.git
cd $(basename $_ .git)
go mod tidy
go build -o gores ./cmd
```
---
### 📚 Documentation
For full docs and usage examples, see [README.md](https://github.com/${{ github.repository }}#readme)
---
_Built automatically via GitHub Actions._
env:
GITHUB_TOKEN: ${{ secrets.MY_PAT }}
- name: Upload Linux binary
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
asset_path: release/gores
asset_name: gores-linux-amd64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.MY_PAT }}
- name: Upload macOS binary
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
asset_path: release/gores
asset_name: gores-darwin-amd64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.MY_PAT }}
- name: Upload Windows binary
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
asset_path: release/gores.exe
asset_name: gores-windows-amd64.exe
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.MY_PAT }}