-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
104 lines (92 loc) · 2.52 KB
/
.gitlab-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
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Go.gitlab-ci.yml
image: golang:1.22-alpine
variables:
# Please edit to your GitLab project
REPO_NAME: git.ftb.dev/Jake_Evans/ftb-debug
# The problem is that to be able to use go get, one needs to put
# the repository in the $GOPATH. So for example if your gitlab domain
# is gitlab.com, and that your repository is namespace/project, and
# the default GOPATH being /go, then you'd need to have your
# repository in /go/src/gitlab.com/namespace/project
# Thus, making a symbolic link corrects this.
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- apk add --no-cache zip
stages:
- build
- deploy
- package
.build:
stage: build
script:
- go build -ldflags "-X 'main.GitCommit=$CI_COMMIT_SHORT_SHA' $EXTRA_FLAGS" -o $CI_PROJECT_DIR/ftb-debug$FILE_OUTPUT
artifacts:
paths:
- ftb-debug$FILE_OUTPUT
expire_in: 1 day
build_linux:
extends: .build
variables:
CGO_ENABLED: 0
GOOS: linux
FILE_OUTPUT: "-linux"
EXTRA_FLAGS: "-extldflags '-static'"
build_linuxArm:
extends: .build
variables:
CGO_ENABLED: 0
GOOS: linux
GOARCH: arm64
FILE_OUTPUT: "-linux-arm"
# EXTRA_FLAGS: "-linkmode external -extldflags '-static'"
build_windows:
extends: .build
variables:
CGO_ENABLED: 0
GOOS: windows
FILE_OUTPUT: ".exe"
build_windowsArm:
extends: .build
variables:
CGO_ENABLED: 0
GOOS: windows
GOARCH: arm64
FILE_OUTPUT: "-arm64.exe"
build_macos:
extends: .build
variables:
CGO_ENABLED: 0
GOOS: darwin
FILE_OUTPUT: "-macos"
build_macos-m1:
extends: .build
variables:
CGO_ENABLED: 0
GOOS: darwin
GOARCH: arm64
FILE_OUTPUT: "-macos-arm64"
package:
stage: package
script:
- echo "packaging everything here"
# - zip -r ftb-debug-$CI_COMMIT_SHORT_SHA ftb-debug*
# - chmod +x upx.sh && ./upx.sh
needs:
- build_linux
- build_linuxArm
- build_windows
- build_windowsArm
- build_macos
- build_macos-m1
artifacts:
name: all-binaries-$CI_COMMIT_SHORT_SHA
untracked: true
# paths:
# - "ftb-debug-$CI_COMMIT_SHORT_SHA.zip"
expire_in: 1 week