Skip to content

Commit 5249a05

Browse files
committed
Integrating build:prerelease job for publishing staging NPM packages
Changing to typescript-demo-lib-native
1 parent 5527ce8 commit 5249a05

File tree

4 files changed

+63
-70
lines changed

4 files changed

+63
-70
lines changed

.gitlab-ci.yml

Lines changed: 56 additions & 63 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
51+
- if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
52+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
53+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
5254
when: manual
53-
- if: $CI_COMMIT_BRANCH == 'master'
54-
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.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
63+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
64+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
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.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
83+
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_BRANCH != 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
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,17 @@ 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
115-
- if: $CI_COMMIT_BRANCH == 'staging'
107+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
108+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
116109

117110
build:windows:
118111
stage: build
119112
needs:
120-
- check:lint
113+
- job: check:lint
114+
optional: true
121115
tags:
122116
- windows
123117
before_script:
@@ -138,16 +132,14 @@ build:windows:
138132
paths:
139133
- ./prebuilds/
140134
rules:
141-
- if: $CI_COMMIT_TAG
142-
when: manual
143-
- if: $CI_COMMIT_BRANCH == 'master'
144-
when: manual
145-
- if: $CI_COMMIT_BRANCH == 'staging'
135+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
136+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
146137

147138
build:macos:
148139
stage: build
149140
needs:
150-
- check:lint
141+
- job: check:lint
142+
optional: true
151143
tags:
152144
- shared-macos-amd64
153145
image: macos-11-xcode-12
@@ -174,11 +166,30 @@ build:macos:
174166
paths:
175167
- ./prebuilds/
176168
rules:
177-
- if: $CI_COMMIT_TAG
178-
when: manual
179-
- if: $CI_COMMIT_BRANCH == 'master'
180-
when: manual
181-
- if: $CI_COMMIT_BRANCH == 'staging'
169+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
170+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
171+
172+
build:prerelease:
173+
stage: build
174+
needs:
175+
- build:linux
176+
- build:windows
177+
- build:macos
178+
# Don't interrupt publishing job
179+
interruptible: false
180+
allow_failure: true
181+
before_script:
182+
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
183+
script:
184+
- >
185+
nix-shell --run '
186+
npm publish --tag prerelease --access public;
187+
'
188+
after_script:
189+
- rm -f ./.npmrc
190+
rules:
191+
# Only prerelease tag
192+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.*[0-9]+$/
182193

183194
integration:builds:
184195
stage: integration
@@ -213,11 +224,8 @@ integration:builds:
213224
paths:
214225
- ./builds/
215226
rules:
216-
- if: $CI_COMMIT_TAG
217-
when: manual
218-
- if: $CI_COMMIT_BRANCH == 'master'
219-
when: manual
220-
- if: $CI_COMMIT_BRANCH == 'staging'
227+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
228+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
221229

222230
integration:nix:
223231
stage: integration
@@ -232,11 +240,8 @@ integration:nix:
232240
)"
233241
- $build_application/bin/typescript-demo-lib
234242
rules:
235-
- if: $CI_COMMIT_TAG
236-
when: manual
237-
- if: $CI_COMMIT_BRANCH == 'master'
238-
when: manual
239-
- if: $CI_COMMIT_BRANCH == 'staging'
243+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
244+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
240245

241246
integration:docker:
242247
stage: integration
@@ -253,11 +258,8 @@ integration:docker:
253258
- image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)"
254259
- docker run "$image"
255260
rules:
256-
- if: $CI_COMMIT_TAG
257-
when: manual
258-
- if: $CI_COMMIT_BRANCH == 'master'
259-
when: manual
260-
- if: $CI_COMMIT_BRANCH == 'staging'
261+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
262+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
261263

262264
integration:linux:
263265
stage: integration
@@ -267,11 +269,8 @@ integration:linux:
267269
script:
268270
- for f in ./builds/*-linux-*; do "$f"; done
269271
rules:
270-
- if: $CI_COMMIT_TAG
271-
when: manual
272-
- if: $CI_COMMIT_BRANCH == 'master'
273-
when: manual
274-
- if: $CI_COMMIT_BRANCH == 'staging'
272+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
273+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
275274

276275
integration:windows:
277276
stage: integration
@@ -282,11 +281,8 @@ integration:windows:
282281
script:
283282
- Get-ChildItem -File ./builds/*-win-* | ForEach {& $_.FullName}
284283
rules:
285-
- if: $CI_COMMIT_TAG
286-
when: manual
287-
- if: $CI_COMMIT_BRANCH == 'master'
288-
when: manual
289-
- if: $CI_COMMIT_BRANCH == 'staging'
284+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
285+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
290286

291287
integration:macos:
292288
stage: integration
@@ -298,11 +294,8 @@ integration:macos:
298294
script:
299295
- for f in ./builds/*-macos-x64*; do "$f"; done
300296
rules:
301-
- if: $CI_COMMIT_TAG
302-
when: manual
303-
- if: $CI_COMMIT_BRANCH == 'master'
304-
when: manual
305-
- if: $CI_COMMIT_BRANCH == 'staging'
297+
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
298+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
306299

307300
# packages:
308301
# stage: release

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# TypeScript-Demo-Lib
1+
# TypeScript-Demo-Lib-Native
22

3-
[![pipeline status](https://gitlab.com/MatrixAI/open-source/TypeScript-Demo-Lib/badges/master/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/TypeScript-Demo-Lib/commits/master)
3+
[![pipeline status](https://gitlab.com/MatrixAI/open-source/TypeScript-Demo-Lib-Native/badges/master/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/TypeScript-Demo-Lib-Native/commits/master)
44

55
## Installation
66

@@ -174,7 +174,7 @@ This has to be done to both `node2nixProd` and `node2nixDev`.
174174
npm run docs
175175
```
176176

177-
See the docs at: https://matrixai.github.io/TypeScript-Demo-Lib/
177+
See the docs at: https://matrixai.github.io/TypeScript-Demo-Lib-Native/
178178

179179
### Publishing
180180

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "@matrixai/typescript-demo-lib",
2+
"name": "@matrixai/typescript-demo-lib-native",
33
"version": "1.3.1",
44
"bin": {
55
"typescript-demo-lib": "dist/bin/typescript-demo-lib.js"
66
},
77
"author": "Roger Qiu",
8-
"description": "TypeScript Demo Library Project",
8+
"description": "TypeScript Demo Library Native Project",
99
"license": "Apache-2.0",
1010
"repository": {
1111
"type": "git",
12-
"url": "https://github.com/MatrixAI/TypeScript-Demo-Lib.git"
12+
"url": "https://github.com/MatrixAI/TypeScript-Demo-Lib-Native.git"
1313
},
1414
"main": "dist/index.js",
1515
"types": "dist/index.d.ts",

shell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ in
1616
PKG_CACHE_PATH = utils.pkgCachePath;
1717
PKG_IGNORE_TAG = 1;
1818
shellHook = ''
19-
echo 'Entering Typescript-Demo-Lib'
19+
echo 'Entering Typescript-Demo-Lib-Native'
2020
set -o allexport
2121
. ./.env
2222
set +o allexport

0 commit comments

Comments
 (0)