-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
116 lines (110 loc) · 3.57 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
stages:
- test
- build
- containerize
- pre-release
- release
test:
variables:
GIT_DEPTH: 999
stage: test
image: mcr.microsoft.com/dotnet/sdk:8.0
script:
- dotnet restore
- dotnet test
build:
stage: build
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
parallel:
matrix:
- { BUILD_ARCH: "win-x64" }
- { BUILD_ARCH: "linux-x64" }
- { BUILD_ARCH: "linux-musl-x64" }
- { BUILD_ARCH: "linux-musl-arm64" }
- { BUILD_ARCH: "linux-musl-arm" }
- { BUILD_ARCH: "osx-x64" }
- { BUILD_ARCH: "osx-arm64" }
image: mcr.microsoft.com/dotnet/sdk:8.0
script:
- dotnet restore cc-gen/cc-gen.csproj
- dotnet publish cc-gen/cc-gen.csproj -c Release --self-contained true -r ${BUILD_ARCH} -v m --version-suffix ${CI_COMMIT_TAG} -o release/${BUILD_ARCH}
- $(cd release/${BUILD_ARCH} && tar -czf ${CI_PROJECT_DIR}/cc-gen-v${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz *)
artifacts:
paths:
- release/
- cc-gen-v${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz
expire_in: 1 day
containerize:
stage: containerize
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
image: registry.gitlab.com/jitesoft/dockerfiles/misc:latest
script:
- mv release/linux-musl-x64 release/amd64
- mv release/linux-musl-arm64 release/arm64
- mv release/linux-musl-arm release/arm
- docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push -t ghcr.io/jitesoft/cc-gen-sharp:${CI_COMMIT_TAG} -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} --build-arg "BUILD_TIME=$(date -Iseconds)" --build-arg "VERSION=${CI_COMMIT_TAG}" -f cc-gen/Dockerfile .
tags:
- protected
- buildx
create_release:
variables:
GIT_DEPTH: 999
stage: pre-release
image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
script:
- "cc-gen gen --latest > CHANGELOG.md"
artifacts:
paths:
- CHANGELOG.md
when: on_success
expire_in: 1 hours
tags:
- protected
release:
needs:
- job: create_release
artifacts: true
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: release
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
script:
- echo "Creating release for ${CI_COMMIT_TAG}"
- release-cli create --name "${CI_COMMIT_TAG}" --description "$(cat CHANGELOG.md)" --tag-name "${CI_COMMIT_TAG}"
tags:
- protected
publish_packages:
image: registry.gitlab.com/jitesoft/dockerfiles/misc:latest
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
parallel:
matrix:
- { BUILD_ARCH: "win-x64" }
- { BUILD_ARCH: "linux-x64" }
- { BUILD_ARCH: "linux-musl-x64" }
- { BUILD_ARCH: "linux-musl-arm64" }
- { BUILD_ARCH: "linux-musl-arm" }
- { BUILD_ARCH: "osx-x64" }
- { BUILD_ARCH: "osx-arm64" }
needs:
- job: build
artifacts: true
stage: release
script:
- sha256sum cc-gen-v${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz > cc-gen-v${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz.sha256sum
- 'curl --retry 3 -H "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file cc-gen-v${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/cc-gen/${CI_COMMIT_TAG}/cc-gen-${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz"'
- 'curl --retry 3 -H "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file cc-gen-v${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz.sha256sum "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/cc-gen/${CI_COMMIT_TAG}/cc-gen-${CI_COMMIT_TAG}-${BUILD_ARCH}.tar.gz.sha256sum"'