-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
130 lines (118 loc) · 3.91 KB
/
.gitlab-ci.yml
File metadata and controls
130 lines (118 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# List of stages for jobs, and their order of execution
stages:
- test
- build
- package
- upload
- release
variables:
# Package version can only contain numbers (0-9), and dots (.).
# Must be in the format of X.Y.Z, i.e. should match /\A\d+\.\d+\.\d+\z/ regular expresion.
# See https://docs.gitlab.com/ee/user/packages/generic_packages/#publish-a-package-file
ZIP: $CI_PROJECT_NAME.zip
PACKAGE_VERSION: $CI_COMMIT_TAG
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${PACKAGE_VERSION}"
GIT_SUBMODULE_STRATEGY: normal
GIT_SUBMODULE_FORCE_HTTPS: "true"
.release_job:
rules:
# Only execute when a valid version tag like 1.0, 2.3-dev or similar is given
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^[0-9]+[.][0-9]+([.][0-9]+)?([-a-z])*$/
.test_job:
stage: test
image: codeccoop/wp-test
cache:
- key:
files:
- bin/download-test-deps.sh
paths:
- /tmp/*.zip
- key:
files:
- composer.lock
paths:
- vendor
rules:
# Only execute when a valid version tag like 1.0, 2.3-dev or similar is given
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^[0-9]+[.][0-9]+([.][0-9]+)?([-a-z])*$/
# Run always on MR pointing to master
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
lint:
extends: .test_job
before_script:
- composer -q install
script:
- vendor/bin/phpcbf
phpunit:
extends: .test_job
before_script:
- nohup docker-entrypoint.sh mariadbd 2>&1 >/dev/null &
- composer -q install
- sleep 10
- chmod a+x bin/*
- bin/install-wp-tests.sh
script:
- vendor/bin/phpunit -c phpunit.xml.dist
build:
extends: .release_job
stage: build
image: node:latest
cache:
- key:
files:
- package-lock.json
paths:
- node_modules
script:
- find src -exec sed -i "s/http-bridge/posts-bridge/g" {} \;
- npm install && npm run build
artifacts:
paths:
- posts-bridge/assets/plugin.bundle.js
package:
extends: .release_job
image: codeccoop/wp-cli:latest
stage: package
dependencies: [build]
script:
- find posts-bridge/deps/plugin -name '*.php' -exec sed -i "s/wpct-plugin/posts-bridge/g" {} \;
- find posts-bridge -name '*.php' -exec sed -i "s/wpct_plugin_/posts_bridge_plugin_/g" {} \;
- find posts-bridge -name "*.php" -exec sed -i 's/WPCT_PLUGIN/POSTS_BRIDGE\\Plugin/g' {} \;
- find posts-bridge/deps/http -name '*.php' -exec sed -i "s/http-bridge/posts-bridge/g" {} \;
- find posts-bridge -name '*.php' -exec sed -i "s/http_bridge_/posts_bridge_http_/g" {} \;
- find posts-bridge -name "*.php" -exec sed -i 's/HTTP_BRIDGE_/POSTS_BRIDGE_HTTP_/g' {} \;
- find posts-bridge -name '*.php' -exec sed -i 's/HTTP_BRIDGE/POSTS_BRIDGE\\Http/g' {} \;
- cp .distignore posts-bridge
- wp dist-archive posts-bridge ./$ZIP
artifacts:
paths:
- $ZIP
upload:
extends: .release_job
stage: upload
image: curlimages/curl:latest
dependencies: [package]
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${ZIP} \
${PACKAGE_REGISTRY_URL}/${ZIP}
release:
# Caution, as of 2021-02-02 these assets links require a login, see:
# https://gitlab.com/gitlab-org/gitlab/-/issues/299384
extends: .release_job
stage: release
image: gitlab/glab:latest
dependencies: [package]
variables:
GITLAB_HOST: "$CI_SERVER_URL"
script:
- |
glab auth login \
--job-token $CI_JOB_TOKEN \
--hostname $CI_SERVER_HOST \
--api-protocol $CI_SERVER_PROTOCOL
- |
glab release create $CI_COMMIT_TAG\
--name "Release $CI_COMMIT_TAG" \
--assets-links "[{\"name\":\"${ZIP}\",\"url\":\"${PACKAGE_REGISTRY_URL}\/${ZIP}\",\"link_type\":\"package\",\"direct_asset_path\":\"\/plugins\/bridges\/${ZIP}\"}]"