-
-
Notifications
You must be signed in to change notification settings - Fork 1
208 lines (169 loc) · 7.82 KB
/
deploy.yaml
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
# builds the content of http://github.com/wind-press/windpress
# inspiration from https://github.com/rectorphp/rector-src/blob/main/.github/workflows/build_scoped_rector.yaml
# TODO: trigger the FREE build only when the PRO build is successful. reference: https://github.blog/changelog/2022-09-08-github-actions-use-github_token-with-workflow_dispatch-and-repository_dispatch/
name: Deploy the Plugin
on:
push:
tags:
- '*'
env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: "dev-main"
jobs:
build_scoped_windpress:
# Don't run on forks.
if: github.repository == 'wind-press/windpress'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
# # sometime, when 2 or more consecutive PRs merged, the checkout wind-press/windpress is overlapped
# # and reverting other commit change
# # this should not happen on create a tag, so wait first
# - name: "Wait before checkout wind-press/windpress on create a tag"
# if: "startsWith(github.ref, 'refs/tags/')"
# run: sleep 20
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Use pnpm to install dependencies and build the assets.
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# install dependencies and build the assets
- run: pnpm install
- run: pnpm build
# clean up the dev files
- run: rm -rf assets node_modules package.json pnpm-lock.yaml vite.config.js .npmrc
- run: rm -rf ecs.php rector.php
# scoped using php-scoper.phar which require #[\ReturnTypeWillChange] inside so use php 8.0 for scoping
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
env:
COMPOSER_TOKEN: ${{ secrets.ORG_DEV_PAT }}
# install only prod dependencies
- run: composer install --no-dev --classmap-authoritative --ansi
# copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
- run: rsync --exclude windpress-deploy -av * windpress-deploy --quiet
# humbug/php-scoper requires php ^8.2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
# prefix the namespaces
- run: sh deploy/deploy-scoped.sh windpress-deploy windpress-prefixed
# clone remote repository, so we can push it
- uses: actions/checkout@v4
with:
repository: wind-press/windpress-deployed
ref: main
path: remote-repository
token: ${{ secrets.ORG_DEV_PAT }}
# remove remote files, to avoid piling up dead code in remote repository
- working-directory: remote-repository
run: |
git rm -rf .
git clean -fxd
# copy files to remote repository
- run: cp -a windpress-prefixed/. remote-repository
# clean up the .wordpress-org directory as it is not needed
- run: rm -rf remote-repository/.wordpress-org
# setup git
- working-directory: remote-repository
run: |
git config user.name "Joshua Gugun Siagian"
git config user.email [email protected]
# commit metadata
- name: "Get Git log"
id: git-log
run: |
echo "log<<EOF" >> $GITHUB_OUTPUT
echo "$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='https://github.com/wind-press/windpress/commit/%H %s')" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# publish it to remote repository with tag
- name: "Commit Prefixed - tag"
working-directory: remote-repository
if: "startsWith(github.ref, 'refs/tags/')"
env:
INPUT_LOG: ${{ steps.git-log.outputs.log }}
run: |
git add --all
git commit -m "WindPress ${GITHUB_REF#refs/tags/}" -m "$INPUT_LOG"
git push --quiet origin main
git tag ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}"
git push --quiet origin ${GITHUB_REF#refs/tags/}
# WordPress.org build
# Get the current tag from github.ref, where the tag name is the version number.
# tag name pattern: X.Y.Z, where X, Y, Z are integers
# reduce the Y by 1, then build the tag name
# save the tag name as `WP_ORG_VERSION` variable to file $GITHUB_ENV
# Note, set-output is deprecated, so use alternative instead of ::set-output
- run: |
echo "WP_ORG_VERSION=$(echo ${GITHUB_REF#refs/tags/} | awk -F. '{print $1"."$2-1"."$3}')" >> $GITHUB_ENV
- run: ls -la
# remove the $NESTED_DIRECTORY directory
- run: rm -rf windpress-deploy remote-repository windpress-prefixed
# remove the vendor directory
- run: rm -rf vendor
# keep this folders (Free):
# - Gutenberg
# - Elementor
# - GreenShift
# - Kadence
# - Timber
# - LiveCanvas
# - Builderius (Planned)
# else, remove the premium version
- run: rm -rf src/Integration/{Blockstudio,Builderius,Breakdance,Beaver,Blocksy,Bricks,Cwicly,Divi,MetaBox,Oxygen}
- run: rm -rf assets/integration/{breakdance,bricks,builderius,livecanvas,oxygen}
- run: ls -la
# scoped using php-scoper.phar which require #[\ReturnTypeWillChange] inside so use php 8.0 for scoping
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
env:
COMPOSER_TOKEN: ${{ secrets.ORG_DEV_PAT }}
# remove custom update library
- run: composer remove rosua/edd-sl-plugin-updater --ansi
# decrease the version
- run: php ./deploy/decrease-version.php
# cleanup the decrease-version.php to avoid scanned by humbug/php-scoper
- run: rm deploy/decrease-version.php
# install only prod dependencies
- run: composer install --no-dev --classmap-authoritative --ansi
# copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
- run: rsync --exclude windpress-deploy -av * windpress-deploy --quiet
# humbug/php-scoper requires php ^8.2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
# prefix the namespaces
- run: sh deploy/deploy-scoped.sh windpress-deploy windpress-prefixed
# deploy to WordPress.org SVN repository
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: windpress
BUILD_DIR: windpress-prefixed
VERSION: ${{ env.WP_ORG_VERSION }}