-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
200 lines (190 loc) · 6.32 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
stages: # List of stages for jobs, and their order of execution
- check
- publish
- prerelease
- release
always-yes:
image: alpine:latest
stage: check
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- echo "Done!"
check:
image: registry.gitlab.com/smoores/storyteller-base:latest
stage: check
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- "docs/docs/**/*"
- "docs/src/**/*"
- "**/*.ts"
- "**/*.js"
- "**/*.json"
- "**/*.tsx"
- yarn.lock
script:
- yarn
- patch -p1 node_modules/pymport/src/pymport.h
web/pymport-swallow-unthrowable.patch
- npm rebuild --build-from-source pymport
- yarn check
- git fetch origin main --depth 1
- ./scripts/check-versions.sh
# At the moment, we only have tests for the web package,
# so there's no need to run them if that hasn't changed.
- if [ "$(git diff origin/main -- web)" ]; then yarn test; fi
check-version:
stage: prerelease
image: node:20
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- cd web
- PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
- ../scripts/if-version-change.sh git tag web-v${PACKAGE_VERSION}
- cd ../docs
- PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
- ../scripts/if-version-change.sh git tag docs-v${PACKAGE_VERSION}
- cd ../mobile
- PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
- ../scripts/if-version-change.sh git tag mobile-v${PACKAGE_VERSION}
- cd ..
- apt update && apt install -y --no-install-recommends git-lfs
- git remote set-url origin
https://ci-push-tag-token:${CI_PUSH_TAG_TOKEN}@gitlab.com/smoores/storyteller.git
- git push --tags
pages:
tags:
- self-managed
image: node:18-alpine
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^docs-v?\d+\.\d+\.\d+$/'
script:
- yarn workspaces focus @storyteller/docs
- yarn build:docs
artifacts:
paths:
- public
publish-web:
tags:
- self-managed
image: docker:24.0.5
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^web-v?\d+\.\d+\.\d+$/'
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker context create gitlab-ci
- docker buildx create --use --driver=docker-container gitlab-ci
script:
- docker buildx build --push -f Dockerfile --cache-from
type=registry,ref=$CI_REGISTRY_IMAGE/cache:latest --cache-to
type=registry,ref=$CI_REGISTRY_IMAGE/cache:latest,mode=max --tag
$CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
publish-cuda:
tags:
- self-managed
image: docker:24.0.5
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^web-v?\d+\.\d+\.\d+$/'
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker context create gitlab-ci
- docker buildx create --use --driver=docker-container gitlab-ci
script:
- docker buildx build --push -f Dockerfile --build-arg BASE_TAG=cuda-latest
--cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache:cuda-latest
--cache-to type=registry,ref=$CI_REGISTRY_IMAGE/cache:cuda-latest,mode=max
--tag $CI_REGISTRY_IMAGE:cuda-latest --tag
$CI_REGISTRY_IMAGE:cuda-$CI_COMMIT_SHORT_SHA --tag
$CI_REGISTRY_IMAGE:cuda-$CI_COMMIT_TAG .
prerelease-web:
tags:
- self-managed
stage: prerelease
image: alpine:latest
rules:
- if: '$CI_COMMIT_TAG =~ /^web-v?\d+\.\d+\.\d+$/'
script:
- apk add curl jq
- version=$(echo $CI_COMMIT_TAG | sed -r 's/web-//')
- package=$(echo $CI_COMMIT_TAG | sed -r 's/-v\d+\.\d+\.\d+$//')
- 'from_sha=$(curl -H "PRIVATE-TOKEN: $CI_API_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases" | jq -r "first(.[] |
select(.tag_name | startswith(\"$package\")) | .commit.short_id)")'
- to_sha=$CI_COMMIT_SHORT_SHA
- 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=${version}&from=${from_sha}&to=${to_sha}"
| jq -r .notes > release_notes.md'
artifacts:
paths:
- release_notes.md
release-web:
tags:
- self-managed
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: prerelease-web
artifacts: true
rules:
- if: '$CI_COMMIT_TAG =~ /^web-v?\d+\.\d+\.\d+$/'
script:
- echo "Creating release for $CI_COMMIT_TAG"
release:
name: "Release $CI_COMMIT_TAG"
description: release_notes.md
tag_name: "$CI_COMMIT_TAG"
ref: "$CI_COMMIT_SHA"
assets:
links:
- name: "CPU-only build for $CI_COMMIT_TAG"
url: "https://$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
- name: "CUDA-enabled build for $CI_COMMIT_TAG"
url: "https://$CI_REGISTRY_IMAGE:cuda-$CI_COMMIT_SHORT_SHA"
prerelease-mobile:
tags:
- self-managed
stage: prerelease
image: alpine:latest
rules:
- if: '$CI_COMMIT_TAG =~ /^mobile-v?\d+\.\d+\.\d+$/'
script:
- apk add curl jq
- version=$(echo $CI_COMMIT_TAG | sed -r 's/mobile-//')
- package=$(echo $CI_COMMIT_TAG | sed -r 's/-v\d+\.\d+\.\d+$//')
- 'from_sha=$(curl -H "PRIVATE-TOKEN: $CI_API_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases" | jq -r "first(.[] |
select(.tag_name | startswith(\"$package\")) | .commit.short_id)")'
- to_sha=$CI_COMMIT_SHORT_SHA
- 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=${version}&from=${from_sha}&to=${to_sha}"
| jq -r .notes > release_notes.md'
artifacts:
paths:
- release_notes.md
release-mobile:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: prerelease-mobile
artifacts: true
rules:
- if: '$CI_COMMIT_TAG =~ /^mobile-v?\d+\.\d+\.\d+$/'
script:
- echo "Creating release for $CI_COMMIT_TAG"
release:
name: "Release $CI_COMMIT_TAG"
description: release_notes.md
tag_name: "$CI_COMMIT_TAG"
ref: "$CI_COMMIT_SHA"
assets:
links:
- name: "iOS"
url: "https://apps.apple.com/us/app/storyteller-reader/id6474467720"
- name: "Android"
url: "https://play.google.com/store/apps/details?id=dev.smoores.Storyteller"