@@ -13,6 +13,7 @@ stages:
13
13
- build
14
14
- test
15
15
- publish
16
+ - tag
16
17
17
18
18
19
# ===========================================================
@@ -52,6 +53,18 @@ before_script:
52
53
- npm ci --cache $CACHE_DIR --prefer-offline --no-audit --verbose
53
54
54
55
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
+
55
68
build :
56
69
stage : build
57
70
<< : *setup_cache
@@ -69,6 +82,8 @@ test:e2e:
69
82
<< : *setup_cache
70
83
dependencies :
71
84
- build
85
+ needs :
86
+ - build
72
87
script :
73
88
- *install_deps
74
89
- GOOGLE_CHROME_VERSION=$(google-chrome --version | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')
@@ -78,8 +93,44 @@ test:e2e:
78
93
79
94
internal-publish :
80
95
stage : publish
96
+ rules :
97
+ # trigger only for branches, skip tags
98
+ - if : ' $CI_COMMIT_BRANCH == $CI_COMMIT_REF_NAME'
81
99
dependencies :
82
100
- build
101
+ needs :
102
+ - build
83
103
script :
84
104
- npm config set registry $NEXUS3_NPM_REGISTRY
85
105
- 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