Repository navigation
146 lines (125 loc) · 3.87 KB
/
Copy pathdocker_build.yaml
File metadata and controls
146 lines (125 loc) · 3.87 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
name: CI/CD Pipeline
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
name: Test & Quality Assurance
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.4'
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Run go vet
run: go vet ./...
- name: Check formatting
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "Code is not properly formatted. Run 'gofmt -w .'"
gofmt -s -l .
exit 1
fi
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Generate coverage report
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.html
- name: Test vmtest package (without QEMU integration tests)
run: |
cd vmtest
# Run tests with short mode to skip QEMU-dependent tests
go test -v -short
build-and-push:
name: Build and Push Docker Image
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
release:
name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
needs: [test, build-and-push]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.4'
- name: Build release binaries
run: |
# Build for multiple platforms
GOOS=linux GOARCH=amd64 go build -o ignite-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -o ignite-linux-arm64 .
GOOS=darwin GOARCH=amd64 go build -o ignite-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -o ignite-darwin-arm64 .
GOOS=windows GOARCH=amd64 go build -o ignite-windows-amd64.exe .
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
ignite-linux-amd64
ignite-linux-arm64
ignite-darwin-amd64
ignite-darwin-arm64
ignite-windows-amd64.exe
generate_release_notes: true
make_latest: true