-
Notifications
You must be signed in to change notification settings - Fork 55
99 lines (84 loc) · 3.01 KB
/
build-status.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
name: Build Status
on:
push:
branches:
- trunk
workflow_dispatch:
jobs:
# Creates a complete build of the plugin.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Logs debug information about the runner container.
# - Installs Composer dependencies (use cache if possible).
# - Make Composer packages available globally.
# - Installs Node dependencies
# - Run the plugin build scripts
build-plugin:
name: Create an installable plugin
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer, cs2pr
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache NodeJS modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Log debug information
run: |
php --version
node --version
composer --version
npm --version
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-progress --no-ansi --no-interaction --no-dev"
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Install Node dependencies
run: npm install
- name: Build plugin
run: npm run build
# Build a zip of master, but only if this is a push workflow scenario.
- name: Set plugin build version
if: ${{ github.event_name == 'push' }}
run: |
echo "::group::Get current plugin version"
current_plugin_version_string=$(grep -oP '^.+?\* Version:\s+\K\S+$' health-check.php)
echo "::endgroup::"
echo "::group::Fetch current commit hash"
current_commit_reference=$(git rev-parse --short "$GITHUB_SHA")
echo "::endgroup::"
echo "::group::Create new temporary version string"
new_plugin_version_string="${current_plugin_version_string}-${current_commit_reference}"
echo "::endgroup::"
echo "::group::Replace version strings in plugin"
grep -rl $current_plugin_version_string . | xargs sed -i "s/$current_plugin_version_string/$new_plugin_version_string/g"
echo "::endgroup::"
- name: Create plugin zip
if: ${{ github.event_name == 'push' }}
run: npm run plugin-zip
- name: Upload zip of master at this time
uses: actions/upload-artifact@v2
if: ${{ github.event_name == 'push' }}
with:
name: health-check-latest
path: health-check.zip