forked from silkeh/alertmanager_matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
77 lines (72 loc) · 1.91 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
---
include:
- project: slxh/pipelines
file:
- golang.gitlab-ci.yml
- builds/docker-buildx.gitlab-ci.yml
variables:
PACKAGE_REGISTRY_URL:
${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/alertmanager_matrix
CGO_ENABLED: 0
build:
stage: build
needs: []
parallel:
matrix:
- GOOS: darwin
GOARCH: [amd64, arm64]
- GOOS: freebsd
GOARCH: [386, amd64, arm]
- GOOS: linux
GOARCH: [386, amd64, arm, arm64, ppc64, ppc64le,
mips, mipsle, mips64, mips64le, riscv64, s390x]
- GOOS: openbsd
GOARCH: [386, amd64, arm, arm64]
- GOOS: windows
GOARCH: [386, amd64, arm, arm64]
script:
- go build -ldflags="-s -w" ./cmd/alertmanager_matrix
- tar -cavf alertmanager_matrix-$GOOS-$GOARCH.tar.gz ./alertmanager_matrix*
artifacts:
name: alertmanager_matrix-$GOOS-$GOARCH
paths:
- "*.tar.gz"
sources:
stage: build
needs: []
script:
- go mod vendor
- tar --exclude-from=.gitignore -caf sources.tar.gz *
artifacts:
paths:
- sources.tar.gz
package rpm:
stage: build
needs: [sources]
image: fedora
script:
- dnf -q -y --setopt=install_weak_deps=False install git golang fedora-packager rpmdevtools
- make rpm
artifacts:
paths:
- "*.rpm"
- "**/*.rpm"
release:
stage: deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- apk add curl
- |
set -x
args=""
for i in *.tar.gz *.rpm **/*.rpm; do
url="${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG}/$(basename "$i")"
args="${args} --assets-link {\"name\":\"$i\",\"url\":\"${url}\"}"
curl -sSf --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "$i" "${url}" || exit 1
done
release-cli create \
--name "Alertmanager Matrix $CI_COMMIT_TAG" \
--tag-name "$CI_COMMIT_TAG" \
$args
rules:
- if: $CI_COMMIT_TAG