-
Notifications
You must be signed in to change notification settings - Fork 0
262 lines (227 loc) · 8.91 KB
/
release-plugin.yml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Release (and deploy) plugin package
# Deploy when a new release is created in the Main branch
on:
release:
# Only deploy when the admin publishes/pre-releases from GitHub
types: [published]
jobs:
plugin_tests:
strategy:
matrix:
php_version: [ '7.3', '7.4', '8.0' ]
name: "Plugin tests - PHP"
runs-on: ubuntu-18.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
repository: eighty20results/Utilities
ref: main
# Extract the branch name for all events except for pull requests
- name: Extract branch or tag name
id: branch-name
uses: tj-actions/branch-names@v7.0.7
- name: Setup PHP with Composer V2+
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
extensions: mbstring, xdebug
tools: composer:v2
coverage: pcov
- name: Login to Docker HUB
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
- name: Load cached Composer and test related dependencies
uses: actions/cache@v2
id: composer-cache
with:
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache
path: inc/**
- name: Install all needed dependencies for Composer
shell: bash
if: steps.restore-cache.outputs.cache-hit != 'true'
run: make composer-dev
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Install all needed WordPress plugin dependencies
shell: bash
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make wp-deps
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Install all needed dependencies for Docker
shell: bash
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make docker-deps
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Run all Standard Tests
shell: bash
run: make tests
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
GITHUB_TOKEN: ${{ secrets.GITHUB }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_ACCESS_TOKEN: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
# To create the plugin .zip archive
build_plugin:
name: Build plugin package to the plugin repository (Our License server or WordPress.org)
needs: [plugin_tests]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
repository: eighty20results/Utilities
ref: main
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding deployment target to known_hosts file
run: ssh-keyscan -H -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: "Setup PHP with Composer V2+"
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, xdebug
tools: composer:v2
coverage: pcov
- name: Login to Docker HUB
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
- name: Load cached Composer and test related dependencies
uses: actions/cache@v2
id: composer-cache
with:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache
path: inc/
- name: Install all needed dependencies for Composer
shell: bash
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make composer-dev
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Install all needed WordPress plugin dependencies
shell: bash
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make wp-deps
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Install all needed dependencies for Docker
shell: bash
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make docker-deps
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Cache the built plugin package
uses: actions/cache@v2
id: plugin-package-cache
with:
key: ${{ runner.os }}-plugin-package-cache-${{ hashFiles('**/build/kits/**.zip') }}
restore-keys: ${{ runner.os }}-plugin-package-cache
path: build/kits/**.zip
- name: Build and test plugin before deployment
shell: bash
run: make build
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
GITHUB_TOKEN: ${{ secrets.GITHUB }}
CONTAINER_ACCESS_TOKEN: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
# To push the release to the plugin store
release:
name: Deploy plugin package to the plugin repository (Our License server or WordPress.org)
needs: [plugin_tests, build_plugin]
runs-on: ubuntu-18.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
repository: eighty20results/Utilities
ref: main
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding deployment target to known_hosts file
shell: bash
run: ssh-keyscan -H -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Login to Docker HUB
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
- name: Setup PHP with Composer V2+
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, xdebug
tools: composer:v2
coverage: pcov
- name: Load cached Composer and test related dependencies (Production)
uses: actions/cache@v2
id: composer-cache-prod
with:
key: ${{ runner.os }}-composer-cache-prod-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache-prod
path: inc/
- name: Install all needed dependencies for Composer
if: steps.composer-cache-prod.outputs.cache-hit != 'true'
shell: bash
run: make composer-dev
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Install all needed WordPress plugin dependencies
if: steps.composer-cache-prod.outputs.cache-hit != 'true'
shell: bash
run: make wp-deps
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Install all needed dependencies for Docker
if: steps.composer-cache-prod.outputs.cache-hit != 'true'
shell: bash
run: make docker-deps
env:
E20R_PLUGIN_NAME: 00-e20r-utilities
- name: Restore the built plugin package
id: plugin-package-cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-plugin-package-cache-${{ hashFiles('**/build/kits/**.zip') }}
restore-keys: ${{ runner.os }}-plugin-package-cache
path: build/kits/**.zip
# Extract the branch name for all events except for pull requests
- name: Decide whether to run deploy action
id: branch-name
uses: tj-actions/branch-names@v7.0.7
- name: Show me the branch
shell: bash
run: |
echo "Reference branch is: ${{ steps.branch-name.outputs.ref_branch }}"
echo "Current branch is: ${{ steps.branch-name.outputs.current_branch }}"
echo "Tag is: ${{ steps.branch-name.outputs.tag }}"
echo "Tag state is: '${{ steps.branch-name.outputs.is_tag }}'"
# And then deploy the package if it exists _and_ we're on the main branch with a release tag
- name: Deploy plugin when building a release (to WooCommerce Store or Wordpress.org repo)
if: steps.branch-name.outputs.is_tag && startsWith(steps.branch-name.outputs.tag, 'release-')
shell: bash
run: make deploy
# The deployment target will depend on whether the
# E20R_SSH_USER or SVN_USERNAME environment variable is defined
env:
BRANCH_NAME: ${{ steps.branch-name.outputs.tag }}
E20R_PLUGIN_NAME: 00-e20r-utilities
GITHUB_TOKEN: ${{ secrets.GITHUB }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_ACCESS_TOKEN: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
E20R_SSH_SERVER: ${{ secrets.SSH_HOST }}
E20R_SSH_USER: ${{ secrets.SSH_USER }}
E20R_SSH_PORT: ${{ secrets.SSH_PORT }}