-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
205 lines (187 loc) · 4.43 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
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
stages:
- lint
- dependencies
- build
- push
- release
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_REF_PROTECTED == "true"
variables:
DOCKERIO_MIRROR: hub.wuhoo.xyz
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo
.cache:
cache:
untracked: false
paths:
- .cargo/.crates.toml
- .cargo/.crates2.json
- .cargo/bin/
- .cargo/registry/index/
- .cargo/registry/cache/
- target/
.lint:
extends: .cache
stage: lint
image: docker.io/library/rust:1.82.0
before_script:
- cargo version
- rustup component add clippy
- rustup component add rustfmt
.non-release:
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
.release:
artifacts:
expire_in: never
rules:
- if: $CI_COMMIT_TAG
when: on_success
lint:clippy:
extends:
- .lint
cache:
key: clippy
script:
- cargo clippy -- -D warnings
lint:format:
extends:
- .lint
cache:
key: format
script:
- cargo fmt -- --check
dependencies:libs:
stage: dependencies
image:
name: docker.io/library/golang:1.23.3-bookworm
cache:
paths:
- .go
variables:
CGO_ENABLED: 1
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
- go version
script:
- cd go
- go mod download
- go mod verify
- go build -v -ldflags "-s -w" -trimpath -buildmode=c-archive -o libshoutrrr.a shoutrrr.go
- cd ..
artifacts:
untracked: false
expire_in: 1 day
paths:
- go/libshoutrrr.a
- go/libshoutrrr.h
when: on_success
.build_binary:
extends: .cache
stage: build
image: docker.io/library/rust:1.82.0
needs:
- lint:clippy
- lint:format
- dependencies:libs
before_script:
- cargo version
artifacts:
untracked: false
expire_in: 7 days
.build_binary:gnu:
extends: .build_binary
script:
- cargo install --locked --target x86_64-unknown-linux-gnu --path .
- mv -v ${CARGO_HOME}/bin/${CI_PROJECT_NAME} ${CI_PROJECT_NAME}_x86_64-unknown-linux-gnu
cache:
key: gnu
artifacts:
paths:
- ${CI_PROJECT_NAME}_x86_64-unknown-linux-gnu
build:container:
stage: build
image:
name: quay.io/buildah/stable:v1.37.5
variables:
STORAGE_DRIVER: vfs
BUILDAH_FORMAT: docker
BUILDAH_ISOLATION: chroot
CGO_ENABLED: 0
needs:
- lint:clippy
- lint:format
before_script:
- echo "${CI_REGISTRY_PASSWORD}" | buildah login -u "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}"
script:
- >-
buildah build
--layers
--cache-to "${CI_REGISTRY_IMAGE}/build-cache"
--cache-from "${CI_REGISTRY_IMAGE}/build-cache"
--cache-ttl 168h0m0s
--tag ${CI_PROJECT_NAME}
--file Dockerfile
.
- buildah push localhost/${CI_PROJECT_NAME} docker-archive:image.tar
artifacts:
untracked: false
expire_in: 1 day
paths:
- image.tar
when: on_success
build:binary:gnu:
extends:
- .build_binary:gnu
- .non-release
build:binary:gnu:release:
extends:
- .build_binary:gnu
- .release
.push:
stage: push
image:
name: gcr.io/go-containerregistry/crane/debug:v0.15.2
entrypoint: [""]
needs:
- build:container
push:
extends: .push
script:
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane push image.tar ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
- crane push image.tar ${CI_REGISTRY_IMAGE}:latest
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
push:release:
extends:
- .push
- .release
script:
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane push image.tar ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
- crane push image.tar ${CI_REGISTRY_IMAGE}:stable
release:
extends: .release
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0
needs:
- build:binary:gnu:release
- push:release
script:
- echo "Creating release for $CI_COMMIT_TAG"
release:
name: "Release $CI_COMMIT_TAG"
description: './release-notes/$CI_COMMIT_TAG/CHANGELOG.md'
tag_name: "$CI_COMMIT_TAG"
ref: "$CI_COMMIT_TAG"
assets:
links:
- name: '${CI_PROJECT_NAME}_x86_64-unknown-linux-gnu'
url: '$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/${CI_PROJECT_NAME}_x86_64-unknown-linux-gnu?job=build:binary:gnu:release'