-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (86 loc) · 4.17 KB
/
release.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
name: Build and attach releases
# When a new release is created on GitHub, this action runs, builds the plugin, adds
# the GitHub updater, zips and attaches the zip to the release.
# yahnis-elsts/plugin-update-checker
# TODO: now, release name must match exactly the plugin base file's version.
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
php: [ '7.4' ]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: master
- name: Install PHP
uses: shivammathur/setup-php@2.11.0
with:
php-version: ${{ matrix.php }}
tools: composer, cs2pr
extensions: zip
- name: Read .env.testing
uses: c-py/action-dotenv-to-setenv@v2
with:
env-file: .env.testing
- name: Read .env.github
uses: c-py/action-dotenv-to-setenv@v2
with:
env-file: .env.github
- name: Set env database host w/port
run: echo "TEST_SITE_DB_HOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
- name: Configure MySQL
run: |
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE USER '"$TEST_DB_USER"'@'%' IDENTIFIED WITH mysql_native_password BY '"$TEST_DB_PASSWORD"';";
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE DATABASE "$TEST_SITE_DB_NAME"; USE "$TEST_SITE_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_SITE_DB_NAME".* TO '"$TEST_DB_USER"'@'%';";
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE DATABASE "$TEST_DB_NAME"; USE "$TEST_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_DB_NAME".* TO '"$TEST_DB_USER"'@'%';";
- name: Create Composer auth.json
run: php -r "file_put_contents( 'auth.json', json_encode( [ 'http-basic' => [ 'blog.brianhenry.ie' => [ 'username' => '"${{ secrets.COMPOSER_AUTH_SECRET }}"', 'password' => 'satispress' ] ] ] ) );"
# - name: Run composer install
# uses: php-actions/composer@v6
# with:
# args: --ignore-platform-reqs
# This appends code for yahnis-elsts/plugin-update-checker at the end of the main plugin file.
- name: Add updater
env:
code: |
\n\n$updateChecker = \$PLUGIN_USNAKE_Puc_v4_Factory::buildUpdateChecker(
'https://github.com/brianhenryie/$PLUGIN_SLUG/',
__FILE__,
'$PLUGIN_SLUG'
);
$updateChecker->setBranch( 'master' );
$updateChecker->getVcsApi()->enableReleaseAssets();
run: |
composer require yahnis-elsts/plugin-update-checker erusev/parsedown;
printf "$code" >> src/$PLUGIN_SLUG.php;
- name: Create wpconfig ... the composer.json creation didn't work
run: |
export $(grep -v '^#' .env.testing | xargs);
sudo vendor/bin/wp config create --dbname=$TEST_SITE_DB_NAME --dbuser=$TEST_SITE_DB_USER --dbpass=$TEST_SITE_DB_PASSWORD --dbhost=127.0.0.1:${{ job.services.mysql.ports['3306'] }} --allow-root --extra-php="define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true );"
- name: Create plugin archive
run: |
vendor/bin/wp dist-archive src --plugin-dirname=$PLUGIN_SLUG
# https://stackoverflow.com/questions/61256824/how-to-pass-the-output-of-a-bash-command-to-github-action-parameter
# echo "DIST_ARCHIVE_OUTPUT=$(vendor/bin/wp dist-archive src --plugin-dirname=bh-wp-account-and-login-ux) >> $GITHUB_ENV
# echo "${{ env.DIST_ARCHIVE_OUTPUT }}"
# Success: Created bh-wp-account-and-login-ux.0.1.1.zip
- uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: "$PLUGIN_SLUG.${{ github.event.release.tag_name }}.zip"
gzip: false
allow_override: true