Skip to content

Commit d20556f

Browse files
committed
Integrating build:prerelease job for publishing staging NPM packages
1 parent 77deb90 commit d20556f

File tree

1 file changed

+38
-54
lines changed

1 file changed

+38
-54
lines changed

.gitlab-ci.yml

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,21 @@ check:lint:
4848
npm run lint;
4949
'
5050
rules:
51-
- if: $CI_COMMIT_TAG
52-
when: manual
53-
- if: $CI_COMMIT_BRANCH == 'master'
51+
- if: $CI_COMMIT_BRANCH =~ /^feature.+/
52+
- if: $CI_COMMIT_BRANCH == 'staging'
53+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master'
5454
when: manual
55-
- when: always
5655

5756
check:nix-dry:
5857
stage: check
5958
needs: []
6059
script:
6160
- nix-build -v -v --dry-run ./release.nix
6261
rules:
63-
- if: $CI_COMMIT_TAG
64-
when: manual
65-
- if: $CI_COMMIT_BRANCH == 'master'
62+
- if: $CI_COMMIT_BRANCH =~ /^feature.+/
63+
- if: $CI_COMMIT_BRANCH == 'staging'
64+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master'
6665
when: manual
67-
- when: always
6866

6967
check:test:
7068
stage: check
@@ -81,19 +79,15 @@ check:test:
8179
junit:
8280
- ./tmp/junit.xml
8381
rules:
84-
- if: $CI_COMMIT_TAG
85-
when: manual
86-
- if: $CI_COMMIT_BRANCH == 'master'
82+
- if: $CI_COMMIT_BRANCH =~ /^feature.+/
83+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_BRANCH != 'staging'
8784
when: manual
88-
# This job will be overridden by `build:linux`
89-
- if: $CI_COMMIT_BRANCH == 'staging'
90-
when: never
91-
- when: always
9285

9386
build:linux:
9487
stage: build
9588
needs:
96-
- check:lint
89+
- job: check:lint
90+
optional: true
9791
script:
9892
- >
9993
nix-shell --run '
@@ -107,17 +101,16 @@ build:linux:
107101
- ./tmp/junit.xml
108102
paths:
109103
- ./prebuilds/
104+
# Only the build:linux preserves the dist
105+
- ./dist
110106
rules:
111-
- if: $CI_COMMIT_TAG
112-
when: manual
113-
- if: $CI_COMMIT_BRANCH == 'master'
114-
when: manual
115107
- if: $CI_COMMIT_BRANCH == 'staging'
116108

117109
build:windows:
118110
stage: build
119111
needs:
120-
- check:lint
112+
- job: check:lint
113+
optional: true
121114
tags:
122115
- windows
123116
before_script:
@@ -138,16 +131,13 @@ build:windows:
138131
paths:
139132
- ./prebuilds/
140133
rules:
141-
- if: $CI_COMMIT_TAG
142-
when: manual
143-
- if: $CI_COMMIT_BRANCH == 'master'
144-
when: manual
145134
- if: $CI_COMMIT_BRANCH == 'staging'
146135

147136
build:macos:
148137
stage: build
149138
needs:
150-
- check:lint
139+
- job: check:lint
140+
optional: true
151141
tags:
152142
- shared-macos-amd64
153143
image: macos-11-xcode-12
@@ -174,12 +164,30 @@ build:macos:
174164
paths:
175165
- ./prebuilds/
176166
rules:
177-
- if: $CI_COMMIT_TAG
178-
when: manual
179-
- if: $CI_COMMIT_BRANCH == 'master'
180-
when: manual
181167
- if: $CI_COMMIT_BRANCH == 'staging'
182168

169+
build:prerelease:
170+
stage: build
171+
needs:
172+
- build:linux
173+
- build:windows
174+
- build:macos
175+
# Don't interrupt publishing job
176+
interruptible: false
177+
allow_failure: true
178+
before_script:
179+
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
180+
script:
181+
- >
182+
nix-shell --run '
183+
npm publish --tag staging --access public;
184+
'
185+
after_script:
186+
- rm -f ./.npmrc
187+
rules:
188+
# Prerelease commit message
189+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE =~ /^[0-9]+\.[0-9]+\.[0-9]+-.+/
190+
183191
integration:builds:
184192
stage: integration
185193
needs:
@@ -213,10 +221,6 @@ integration:builds:
213221
paths:
214222
- ./builds/
215223
rules:
216-
- if: $CI_COMMIT_TAG
217-
when: manual
218-
- if: $CI_COMMIT_BRANCH == 'master'
219-
when: manual
220224
- if: $CI_COMMIT_BRANCH == 'staging'
221225

222226
integration:nix:
@@ -232,10 +236,6 @@ integration:nix:
232236
)"
233237
- $build_application/bin/typescript-demo-lib
234238
rules:
235-
- if: $CI_COMMIT_TAG
236-
when: manual
237-
- if: $CI_COMMIT_BRANCH == 'master'
238-
when: manual
239239
- if: $CI_COMMIT_BRANCH == 'staging'
240240

241241
integration:docker:
@@ -253,10 +253,6 @@ integration:docker:
253253
- image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)"
254254
- docker run "$image"
255255
rules:
256-
- if: $CI_COMMIT_TAG
257-
when: manual
258-
- if: $CI_COMMIT_BRANCH == 'master'
259-
when: manual
260256
- if: $CI_COMMIT_BRANCH == 'staging'
261257

262258
integration:linux:
@@ -267,10 +263,6 @@ integration:linux:
267263
script:
268264
- for f in ./builds/*-linux-*; do "$f"; done
269265
rules:
270-
- if: $CI_COMMIT_TAG
271-
when: manual
272-
- if: $CI_COMMIT_BRANCH == 'master'
273-
when: manual
274266
- if: $CI_COMMIT_BRANCH == 'staging'
275267

276268
integration:windows:
@@ -282,10 +274,6 @@ integration:windows:
282274
script:
283275
- Get-ChildItem -File ./builds/*-win-* | ForEach {& $_.FullName}
284276
rules:
285-
- if: $CI_COMMIT_TAG
286-
when: manual
287-
- if: $CI_COMMIT_BRANCH == 'master'
288-
when: manual
289277
- if: $CI_COMMIT_BRANCH == 'staging'
290278

291279
integration:macos:
@@ -298,10 +286,6 @@ integration:macos:
298286
script:
299287
- for f in ./builds/*-macos-x64*; do "$f"; done
300288
rules:
301-
- if: $CI_COMMIT_TAG
302-
when: manual
303-
- if: $CI_COMMIT_BRANCH == 'master'
304-
when: manual
305289
- if: $CI_COMMIT_BRANCH == 'staging'
306290

307291
# packages:

0 commit comments

Comments
 (0)