This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
66 lines (62 loc) · 3.2 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
stages:
- build
- upload
- release
variables:
PACKAGE_VERSION: "0.0.9"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${PACKAGE_VERSION}"
PROJECT_NAME: "nginx-auth-server"
LINUX_386_BINARY: "${PROJECT_NAME}-linux-i386"
LINUX_AMD64_BINARY: "${PROJECT_NAME}-linux-amd64"
LINUX_ARM_BINARY: "${PROJECT_NAME}-linux-arm"
LINUX_ARM64_BINARY: "${PROJECT_NAME}-linux-arm64"
WINDOWS_AMD64_BINARY: "${PROJECT_NAME}-windows-amd64.exe"
GO_BUILD_TAGS: "prod netgo"
compile:
stage: build
rules:
- if: $CI_COMMIT_TAG
script:
- npm i
- npm run build
- mkdir -p ./bin
- "GOOS=linux GOARCH=arm go build -o ./bin/${LINUX_ARM_BINARY} -tags ${GO_BUILD_TAGS} ./src"
- "GOOS=linux GOARCH=arm64 go build -o ./bin/${LINUX_ARM64_BINARY} -tags ${GO_BUILD_TAGS} ./src"
- "GOOS=linux GOARCH=386 go build -o ./bin/${LINUX_386_BINARY} -tags ${GO_BUILD_TAGS} ./src"
- "GOOS=linux GOARCH=amd64 go build -o ./bin/${LINUX_AMD64_BINARY} -tags ${GO_BUILD_TAGS} ./src"
- "GOOS=windows GOARCH=amd64 go build -o ./bin/${WINDOWS_AMD64_BINARY} -tags ${GO_BUILD_TAGS} ./src"
- "tar cfz ./bin/${LINUX_ARM_BINARY}.tar.gz ./bin/${LINUX_ARM_BINARY}"
- "tar cfz ./bin/${LINUX_ARM64_BINARY}.tar.gz ./bin/${LINUX_ARM64_BINARY}"
- "tar cfz ./bin/${LINUX_386_BINARY}.tar.gz ./bin/${LINUX_386_BINARY}"
- "tar cfz ./bin/${LINUX_AMD64_BINARY}.tar.gz ./bin/${LINUX_AMD64_BINARY}"
- "tar cfz ./bin/${WINDOWS_AMD64_BINARY}.tar.gz ./bin/${WINDOWS_AMD64_BINARY}"
artifacts:
paths:
- bin
upload:
stage: upload
rules:
- if: $CI_COMMIT_TAG
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${LINUX_ARM_BINARY}.tar.gz "${PACKAGE_REGISTRY_URL}/${LINUX_ARM_BINARY}.tar.gz"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${LINUX_ARM64_BINARY}.tar.gz "${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_BINARY}.tar.gz"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${LINUX_386_BINARY}.tar.gz "${PACKAGE_REGISTRY_URL}/${LINUX_386_BINARY}.tar.gz"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${LINUX_AMD64_BINARY}.tar.gz "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}.tar.gz"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${WINDOWS_AMD64_BINARY}.tar.gz "${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}.tar.gz"
release_job:
stage: release
rules:
- if: $CI_COMMIT_TAG
script:
- |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"${LINUX_ARM_BINARY}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM_BINARY}.tar.gz\"}" \
--assets-link "{\"name\":\"${LINUX_ARM64_BINARY}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_BINARY}.tar.gz\"}" \
--assets-link "{\"name\":\"${LINUX_386_BINARY}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_386_BINARY}.tar.gz\"}" \
--assets-link "{\"name\":\"${LINUX_AMD64_BINARY}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}.tar.gz\"}" \
--assets-link "{\"name\":\"${WINDOWS_AMD64_BINARY}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}.tar.gz\"}"