-
-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (154 loc) · 5.52 KB
/
ci.yml
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
name: CI/CD Pipeline
on:
push:
paths:
- '**.go'
tags:
- 'v*.*.*' # Triggers the workflow on version tags (e.g., v1.0.0)
pull_request:
paths:
- '**.go'
- '.github/workflows/**'
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v3
# TODO: Move this to a separate re-usable action
- name: Cache Skaffold
id: cache-skaffold
uses: actions/cache@v4
with:
path: |
/usr/local/bin/skaffold
key: skaffold-${{ runner.os }}-${{ hashFiles('**/skaffold.yaml') }}
- name: Install Skaffold
if: steps.cache-skaffold.outputs.cache-hit != 'true'
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: '1.21' # Specify your Go version
- name: Build binary
run: |
mkdir -p dist
BINARY_NAME="kickstart-${{ matrix.goos }}-${{ matrix.goarch }}"
if [[ "${{ matrix.goos }}" == "windows" ]]; then
BINARY_NAME="${BINARY_NAME}.exe"
fi
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/${BINARY_NAME} main.go
- name: Run tests
run: make test
- name: Upload build artifacts
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: kickstart-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/kickstart-${{ matrix.goos }}-${{ matrix.goarch }}
release:
name: Create Release and Upload Assets
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Linux AMD64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-linux-amd64
- name: Download Linux ARM64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-linux-arm64
- name: Download Darwin AMD64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-darwin-amd64
- name: Download Darwin ARM64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-darwin-arm64
- name: Download Windows AMD64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-windows-amd64.exe
- name: Download Windows ARM64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-windows-arm64.exe
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false
- name: List files in dist directory
run: ls -la ./
- name: Upload Linux AMD64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-linux-amd64
asset_name: kickstart-linux-amd64
asset_content_type: application/octet-stream
- name: Upload Linux ARM64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-linux-arm64
asset_name: kickstart-linux-arm64
asset_content_type: application/octet-stream
- name: Upload Darwin AMD64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-darwin-amd64
asset_name: kickstart-darwin-amd64
asset_content_type: application/octet-stream
- name: Upload Darwin ARM64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-darwin-arm64
asset_name: kickstart-darwin-arm64
asset_content_type: application/octet-stream
- name: Upload Windows AMD64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-windows-amd64.exe
asset_name: kickstart-windows-amd64.exe
asset_content_type: application/octet-stream
- name: Upload Windows ARM64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-windows-arm64.exe
asset_name: kickstart-windows-arm64.exe
asset_content_type: application/octet-stream