1- workflow :
2- rules :
3- - if : $CI_COMMIT_BRANCH
4- changes :
5- - README.md
6- - .gitlab-ci.yml
7- when :
8- never
9- # Do no allow manually triggered pipelines to prevent duplicates!
10- # Instead rerun the pipeline created with the last push
11- - if : $CI_PIPELINE_SOURCE != "push"
12- when : never
13- # Only execute when a valid version tag like 1.0, 2.3-dev or similar is given
14- # Required is always one point like 1.0
15- - if : $CI_COMMIT_TAG =~ /^[0-9]+[.][0-9]+([.][0-9]+)?([-a-z])*$/
16-
17- stages : # List of stages for jobs, and their order of execution
1+ # List of stages for jobs, and their order of execution
2+ stages :
3+ - test
184 - build
195 - package
206 - upload
@@ -32,49 +18,113 @@ variables:
3218 GIT_SUBMODULE_STRATEGY : normal
3319 GIT_SUBMODULE_FORCE_HTTPS : " true"
3420
21+ .release_job :
22+ rules :
23+ # Only execute when a valid version tag like 1.0, 2.3-dev or similar is given
24+ - if : $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^[0-9]+[.][0-9]+([.][0-9]+)?([-a-z])*$/
25+
26+ .test_job :
27+ stage : test
28+ image : codeccoop/wp-test
29+ cache :
30+ - key :
31+ files :
32+ - bin/download-test-deps.sh
33+ paths :
34+ - /tmp/*.zip
35+
36+ - key :
37+ files :
38+ - composer.lock
39+ paths :
40+ - vendor
41+ rules :
42+ # Only execute when a valid version tag like 1.0, 2.3-dev or similar is given
43+ - if : $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^[0-9]+[.][0-9]+([.][0-9]+)?([-a-z])*$/
44+ # Run always on MR pointing to master
45+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
46+
47+ lint :
48+ extends : .test_job
49+ before_script :
50+ - composer -q install
51+ script :
52+ - vendor/bin/phpcbf
53+
54+ phpunit :
55+ extends : .test_job
56+ before_script :
57+ - nohup docker-entrypoint.sh mariadbd 2>&1 >/dev/null &
58+ - composer -q install
59+ - sleep 10
60+ - chmod a+x bin/*
61+ - bin/install-wp-tests.sh
62+ - bin/download-test-deps.sh
63+ script :
64+ - vendor/bin/phpunit -c phpunit.xml.dist
65+
3566build :
67+ extends : .release_job
3668 stage : build
3769 image : node:latest
70+ cache :
71+ - key :
72+ files :
73+ - package-lock.json
74+ paths :
75+ - node_modules
3876 script :
3977 - find src -exec sed -i "s/http-bridge/forms-bridge/g" {} \;
4078 - npm install && npm run build
41- - rm -rf node_modules
4279 artifacts :
4380 paths :
44- - assets/plugin.bundle.js
81+ - forms-bridge/ assets/plugin.bundle.js
4582
4683package :
84+ extends : .release_job
4785 image : codeccoop/wp-cli:latest
4886 stage : package
87+ dependencies : [build]
4988 script :
50- - find common -name '*.php' -exec sed -i "s/wpct-plugin/forms-bridge/g" {} \;
51- - find . -name '*.php' -exec sed -i "s/wpct_plugin_/forms_bridge_plugin_/g" {} \;
52- - find . -name "*.php" -exec sed -i 's/WPCT_PLUGIN/FORMS_BRIDGE\\Common/g' {} \;
53- - find deps/http -name '*.php' -exec sed -i "s/http-bridge/forms-bridge/g" {} \;
54- - find . -name '*.php' -exec sed -i "s/http_bridge_/forms_bridge_http_/g" {} \;
55- - find . -name "*.php" -exec sed -i 's/HTTP_BRIDGE_/FORMS_BRIDGE_HTTP_/g' {} \;
56- - find . -name '*.php' -exec sed -i 's/HTTP_BRIDGE/FORMS_BRIDGE\\Http/g' {} \;
57- - find deps/i18n -name '*.php' -exec sed -i "s/wpct-i18n/forms-bridge/g" {} \;
58- - find . -name '*.php' -exec sed -i "s/wpct_i18n_/forms_bridge_i18n_/g" {} \;
59- - find . -name '*.php' -exec sed -i 's/WPCT_I18N/FORMS_BRIDGE\\I18n/g' {} \;
60- - wp dist-archive . ./$ZIP
89+ - find forms-bridge/deps/plugin -name '*.php' -exec sed -i "s/wpct-plugin/forms-bridge/g" {} \;
90+ - find forms-bridge -name '*.php' -exec sed -i "s/wpct_plugin_/forms_bridge_plugin_/g" {} \;
91+ - find forms-bridge -name "*.php" -exec sed -i 's/WPCT_PLUGIN/FORMS_BRIDGE\\Plugin/g' {} \;
92+ - find forms-bridge/deps/http -name '*.php' -exec sed -i "s/http-bridge/forms-bridge/g" {} \;
93+ - find forms-bridge -name '*.php' -exec sed -i "s/http_bridge_/forms_bridge_http_/g" {} \;
94+ - find forms-bridge -name "*.php" -exec sed -i 's/HTTP_BRIDGE_/FORMS_BRIDGE_HTTP_/g' {} \;
95+ - find forms-bridge -name '*.php' -exec sed -i 's/HTTP_BRIDGE/FORMS_BRIDGE\\Http/g' {} \;
96+ - wp dist-archive forms-bridge ./$ZIP
6197 artifacts :
6298 paths :
6399 - $ZIP
64100
65101upload :
102+ extends : .release_job
66103 stage : upload
67104 image : curlimages/curl:latest
105+ dependencies : [package]
68106 script :
69107 - |
70- curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${ZIP} ${PACKAGE_REGISTRY_URL}/${ZIP}
108+ curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
109+ --upload-file ${ZIP} \
110+ ${PACKAGE_REGISTRY_URL}/${ZIP}
71111
72112release :
73113 # Caution, as of 2021-02-02 these assets links require a login, see:
74114 # https://gitlab.com/gitlab-org/gitlab/-/issues/299384
115+ extends : .release_job
75116 stage : release
76- image : registry.gitlab.com/gitlab-org/release-cli:latest
117+ image : gitlab/glab:latest
118+ dependencies : [package]
119+ variables :
120+ GITLAB_HOST : " $CI_SERVER_URL"
77121 script :
78122 - |
79- release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
80- --assets-link "{\"name\":\"${ZIP}\",\"url\":\"${PACKAGE_REGISTRY_URL}\/${ZIP}\",\"link_type\":\"package\",\"filepath\":\"\/plugins\/bridges\/${ZIP}\"}"
123+ glab auth login \
124+ --job-token $CI_JOB_TOKEN \
125+ --hostname $CI_SERVER_HOST \
126+ --api-protocol $CI_SERVER_PROTOCOL
127+ - |
128+ glab release create $CI_COMMIT_TAG\
129+ --name "Release $CI_COMMIT_TAG" \
130+ --assets-links "[{\"name\":\"${ZIP}\",\"url\":\"${PACKAGE_REGISTRY_URL}\/${ZIP}\",\"link_type\":\"package\",\"direct_asset_path\":\"\/plugins\/bridges\/${ZIP}\"}]"
0 commit comments