Skip to content

Commit 68cf84d

Browse files
author
Milos Danilov
committed
release: auto
Merge branch 'feat/npm-publish' into 'master' ci(gitlab-ci): add release-tag stage and job See merge request rabix/cwl-svg!6
2 parents 24cee4a + f26d822 commit 68cf84d

File tree

3 files changed

+4448
-1591
lines changed

3 files changed

+4448
-1591
lines changed

.gitlab-ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ stages:
1313
- build
1414
- test
1515
- publish
16+
- tag
1617

1718

1819
#===========================================================
@@ -52,6 +53,18 @@ before_script:
5253
- npm ci --cache $CACHE_DIR --prefer-offline --no-audit --verbose
5354

5455

56+
# a template for ssh setup
57+
.setup_ssh: &setup_ssh
58+
before_script:
59+
# export the SSH_AUTH_SOCK and SSH_AGENT_PID variables
60+
- eval "$(infinity ssh agent)"
61+
# Use infinity to add gitlab runner to known host for git clone (using ssh)
62+
- infinity ssh set-knownhosts
63+
# We add a custom user for git operations during CI
64+
- git config --global user.email $INFINITY_USER_EMAIL
65+
- git config --global user.name $INFINITY_USER_NAME
66+
67+
5568
build:
5669
stage: build
5770
<<: *setup_cache
@@ -69,6 +82,8 @@ test:e2e:
6982
<<: *setup_cache
7083
dependencies:
7184
- build
85+
needs:
86+
- build
7287
script:
7388
- *install_deps
7489
- GOOGLE_CHROME_VERSION=$(google-chrome --version | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')
@@ -78,8 +93,44 @@ test:e2e:
7893

7994
internal-publish:
8095
stage: publish
96+
rules:
97+
# trigger only for branches, skip tags
98+
- if: '$CI_COMMIT_BRANCH == $CI_COMMIT_REF_NAME'
8199
dependencies:
82100
- build
101+
needs:
102+
- build
83103
script:
84104
- npm config set registry $NEXUS3_NPM_REGISTRY
85105
- infinity npm publish dist
106+
107+
108+
release-tag:
109+
stage: tag
110+
<<: *setup_ssh
111+
<<: *use_cache
112+
rules:
113+
- if: '$CI_COMMIT_BRANCH == "master" && $CI_COMMIT_MESSAGE =~ /^release: auto/'
114+
dependencies:
115+
- build
116+
- test:e2e
117+
needs:
118+
- build
119+
- test:e2e
120+
script:
121+
# we create temporary folder to hold newly cloned project
122+
- PROJECT_CLONE=$(mktemp -d)
123+
# we clone git project into temporary folder
124+
- infinity git clone --destination $PROJECT_CLONE --branch $CI_COMMIT_REF_NAME
125+
# we copy cache directory to cloned project
126+
- if [ -d $CACHE_DIR ]; then cp -r $CACHE_DIR $PROJECT_CLONE/$CACHE_DIR; fi
127+
# we enter the repository root
128+
- cd $PROJECT_CLONE
129+
# now that our repository is up-to-date we need to install dependencies
130+
- *install_deps
131+
# now we can run standard-version
132+
- npm run release:tag
133+
# we push the changes to the triggering branch, including the tag created by standard-version
134+
- infinity git push --include-tags
135+
# remove cloned repository
136+
- rm -rf $PROJECT_CLONE

0 commit comments

Comments
 (0)