forked from tizbac/proxmoxbackupclient_go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
227 lines (206 loc) · 6.19 KB
/
.gitlab-ci.yml
File metadata and controls
227 lines (206 loc) · 6.19 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# GitLab CI/CD Pipeline for Proxmox Backup Guardian GUI
# Multi-platform Go builds with Docker-in-Docker
stages:
- test
- build
- package
- publish
variables:
GO_VERSION: "1.25"
PROJECT_NAME: "NimbusBackup"
# Disable go.work (GUI is independent module)
GOWORK: "off"
# Docker-in-Docker configuration
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
# ==================== TEMPLATES ====================
.go_template: &go_template
image: golang:${GO_VERSION}
cache:
key: ${CI_COMMIT_REF_SLUG}-go
paths:
- .go/pkg/mod/
before_script:
- apt-get update && apt-get install -y gcc libgl1-mesa-dev xorg-dev pkg-config
- mkdir -p .go
- export GOPATH="$CI_PROJECT_DIR/.go"
- export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
- cd gui
.build_template: &build_template
<<: *go_template
stage: build
artifacts:
paths:
- ${PROJECT_NAME}-*
expire_in: 7 days
only:
- main
- master
- develop
- github-release
- tags
# ==================== TEST STAGE ====================
test:code:
<<: *go_template
stage: test
script:
- go mod tidy
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -v ./...
only:
- branches
- merge_requests
- tags
lint:
image: golangci/golangci-lint:v1.64
stage: test
before_script:
- apt-get update && apt-get install -y gcc libgl1-mesa-dev xorg-dev pkg-config
- cd gui
- go mod tidy
script:
- golangci-lint run -v --timeout=5m --verbose --print-issued-lines=true
allow_failure: false
only:
- branches
- merge_requests
- tags
# ==================== BUILD STAGE ====================
build:linux-amd64:
<<: *build_template
before_script:
- apt-get update && apt-get install -y gcc libgl1-mesa-dev xorg-dev
- mkdir -p .go
- export GOPATH="$CI_PROJECT_DIR/.go"
- cd gui
script:
- go mod tidy
- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ../${PROJECT_NAME}-linux-amd64 .
- chmod +x ../${PROJECT_NAME}-linux-amd64
- ls -lh ../${PROJECT_NAME}-linux-amd64
build:linux-arm64:
<<: *build_template
before_script:
# Enable ARM64 architecture for multiarch
- dpkg --add-architecture arm64
- apt-get update
# Install cross-compiler and ARM64 libraries
- apt-get install -y gcc-aarch64-linux-gnu
- apt-get install -y libgl1-mesa-dev:arm64 libx11-dev:arm64 libxrandr-dev:arm64 libxxf86vm-dev:arm64 libxi-dev:arm64 libxcursor-dev:arm64 libxinerama-dev:arm64
# Configure pkg-config for ARM64 cross-compile
- export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
- mkdir -p .go
- export GOPATH="$CI_PROJECT_DIR/.go"
- cd gui
script:
- go mod tidy
- CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -ldflags="-s -w" -o ../${PROJECT_NAME}-linux-arm64 .
- ls -lh ../${PROJECT_NAME}-linux-arm64
build:windows-amd64:
<<: *build_template
before_script:
# Install MinGW cross-compiler for Windows with OpenGL support
- apt-get update && apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
- mkdir -p .go
- export GOPATH="$CI_PROJECT_DIR/.go"
- export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
- cd gui
script:
- go mod tidy
# Cross-compile for Windows with CGO and proper GUI/OpenGL flags
- CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags="-s -w -H windowsgui" -o ../${PROJECT_NAME}-windows-amd64.exe .
- ls -lh ../${PROJECT_NAME}-windows-amd64.exe
build:darwin-amd64:
<<: *build_template
script:
- go mod tidy
- echo "macOS builds require osxcross - skipping for now"
- touch ../${PROJECT_NAME}-darwin-amd64
allow_failure: true
# ==================== PACKAGE STAGE ====================
package:linux:
stage: package
image: ubuntu:22.04
dependencies:
- build:linux-amd64
- build:linux-arm64
before_script:
- apt-get update && apt-get install -y tar gzip zip
script:
- mkdir -p dist
# Package amd64
- cp ${PROJECT_NAME}-linux-amd64 dist/
- cp GUI_README.md dist/README.md || touch dist/README.md
- cp CONFIG_FORMAT_SPEC.md dist/ || true
- cd dist
- tar -czf ../${PROJECT_NAME}-linux-amd64.tar.gz *
- zip -r ../${PROJECT_NAME}-linux-amd64.zip *
- cd ..
- rm -rf dist/*
# Package arm64
- cp ${PROJECT_NAME}-linux-arm64 dist/
- cp GUI_README.md dist/README.md || touch dist/README.md
- cd dist
- tar -czf ../${PROJECT_NAME}-linux-arm64.tar.gz *
- cd ..
artifacts:
paths:
- ${PROJECT_NAME}-linux-*.tar.gz
- ${PROJECT_NAME}-linux-*.zip
expire_in: 30 days
only:
- main
- master
- github-release
- tags
package:windows:
stage: package
image: ubuntu:22.04
dependencies:
- build:windows-amd64
before_script:
- apt-get update && apt-get install -y zip
script:
- mkdir -p dist
- cp ${PROJECT_NAME}-windows-amd64.exe dist/
- cp GUI_README.md dist/README.md || touch dist/README.md
- cp CONFIG_FORMAT_SPEC.md dist/ || true
- cd dist
- zip -r ../${PROJECT_NAME}-windows-amd64.zip *
artifacts:
paths:
- ${PROJECT_NAME}-windows-amd64.zip
expire_in: 30 days
only:
- main
- master
- github-release
- tags
# ==================== PUBLISH STAGE ====================
publish:registry:
stage: publish
image: curlimages/curl:latest
dependencies:
- package:linux
- package:windows
script:
- |
# Determine version (use tag if exists, otherwise use commit sha)
VERSION="${CI_COMMIT_TAG:-${CI_COMMIT_SHORT_SHA}}"
echo "Publishing version: $VERSION"
# Upload each package to GitLab Generic Package Registry
for file in ${PROJECT_NAME}-*.tar.gz ${PROJECT_NAME}-*.zip; do
if [ -f "$file" ]; then
echo "Uploading $file..."
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file "$file" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PROJECT_NAME}/${VERSION}/${file}"
fi
done
echo "Packages published to: ${CI_PROJECT_URL}/-/packages"
only:
- main
- master
- github-release
- tags