-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgov2.yml
139 lines (128 loc) · 4.26 KB
/
gov2.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
stages:
- build
- build docker
- manifest
variables:
BUILDER_IMAGE: dock.mau.dev/tulir/gomuks-build-docker
BINARY_NAME_V2: mautrix-$CI_PROJECT_NAME-v2
GOTOOLCHAIN: local
.build-v2: &build-v2
stage: build
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
- export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }')
- export GO_LDFLAGS="-s -w -linkmode external -extldflags -static -X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date -Iseconds`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'"
script:
- go build -ldflags "$GO_LDFLAGS" -o $BINARY_NAME_V2 ./cmd/$BINARY_NAME_V2
- sha256sum $BINARY_NAME_V2 | tee $BINARY_NAME_V2.sha256sum
artifacts:
paths:
- $BINARY_NAME_V2
.build-docker-v2: &build-docker-v2
image: docker:stable
stage: build docker
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:v2 || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:v2 --tag $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-$DOCKER_ARCH . --file Dockerfile.v2.ci
- docker push $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-$DOCKER_ARCH
after_script:
- docker rmi $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-$DOCKER_ARCH
.build-macos-v2: &build-macos-v2
stage: build
variables:
MACOSX_DEPLOYMENT_TARGET: "11.0"
before_script:
- export PATH=/opt/homebrew/bin:$PATH
- export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }')
- export GO_LDFLAGS="-X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date -Iseconds`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'"
- export LIBRARY_PATH=$(brew --prefix)/lib
- export CPATH=$(brew --prefix)/include
script:
- go build -ldflags "$GO_LDFLAGS" -o $BINARY_NAME_V2 ./cmd/$BINARY_NAME_V2
- install_name_tool -change $(brew --prefix)/opt/libolm/lib/libolm.3.dylib @rpath/libolm.3.dylib $BINARY_NAME_V2
- install_name_tool -add_rpath @executable_path $BINARY_NAME_V2
- install_name_tool -add_rpath /opt/homebrew/opt/libolm/lib $BINARY_NAME_V2
- install_name_tool -add_rpath /usr/local/opt/libolm/lib $BINARY_NAME_V2
- cp $(brew --prefix)/opt/libolm/lib/libolm.3.dylib .
artifacts:
paths:
- $BINARY_NAME_V2
- libolm.3.dylib
build amd64 v2:
<<: *build-v2
image: $BUILDER_IMAGE:linux-amd64
tags:
- linux
- amd64
build arm64 v2:
<<: *build-v2
image: $BUILDER_IMAGE:linux-arm64-native
tags:
- linux
- arm64
build arm v2:
<<: *build-v2
image: $BUILDER_IMAGE:linux-arm
tags:
- linux
- amd64
build macos arm64 v2:
<<: *build-macos-v2
tags:
- macos
- arm64
build docker amd64 v2:
<<: *build-docker-v2
tags:
- linux
- amd64
dependencies:
- build amd64 v2
needs:
- build amd64 v2
variables:
DOCKER_ARCH: amd64
after_script:
- export BEEPER_BRIDGE_TYPE=${BEEPER_BRIDGE_TYPE}v2
- wget "$BEEPER_CD_TOOL_URL" -O bridge-cd-tool && chmod +x bridge-cd-tool && ./bridge-cd-tool
- docker rmi $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-$DOCKER_ARCH
build docker arm64 v2:
<<: *build-docker-v2
tags:
- linux
- arm64
dependencies:
- build arm64 v2
needs:
- build arm64 v2
variables:
DOCKER_ARCH: arm64
manifest v2:
stage: manifest
variables:
GIT_STRATEGY: none
before_script:
- "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
needs:
- build docker amd64 v2
- build docker arm64 v2
script:
- docker pull $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-amd64
- docker pull $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-arm64
- |
if [[ "$CI_COMMIT_BRANCH" == "master" || "$CI_COMMIT_BRANCH" == "main" ]]; then
export MANIFEST_NAME="$CI_REGISTRY_IMAGE:v2"
else
export MANIFEST_NAME="$CI_REGISTRY_IMAGE:v2-${CI_COMMIT_REF_NAME//\//_}"
fi
docker manifest create $MANIFEST_NAME $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-arm64
docker manifest push $MANIFEST_NAME
- docker rmi $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:v2-$CI_COMMIT_SHA-arm64