-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (110 loc) · 5.15 KB
/
release.yml
File metadata and controls
125 lines (110 loc) · 5.15 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
name: Release
on:
schedule:
- cron: '0 6 * * *'
repository_dispatch:
types: [openapi-updated]
workflow_dispatch:
inputs:
version_bump:
description: 'patch | minor | major'
required: false
default: 'patch'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mysqli, zip, gd
tools: composer
coverage: none
# Install dev deps for verification (PHPUnit, PHPStan, PHPCS).
# Re-installed without --dev right before deploy.
- run: composer install --prefer-dist
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- run: npm ci
- name: Regenerate from live OpenAPI
run: npm run generate
- name: Check if spec changed
id: diff
run: |
if git diff --quiet specs/openapi.json src/Generated blocks/generated; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Lint
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: vendor/bin/phpcs --standard=phpcs.xml.dist
- name: Static analysis
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: vendor/bin/phpstan analyze --no-progress --memory-limit=1G
- name: Build blocks
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: npm run build:all
- name: PHPUnit
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
env:
DB_HOST: 127.0.0.1
run: |
sudo apt-get install -y -qq subversion
sudo systemctl start mysql
mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress_test;"
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest true
vendor/bin/phpunit
- name: Reinstall composer without dev deps for shipped vendor/
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: composer install --no-dev --optimize-autoloader --prefer-dist
- name: Bump version
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
id: bump
run: |
BUMP="${{ github.event.inputs.version_bump || 'patch' }}"
npm version "$BUMP" --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
sed -i "s/^\(\s*\*\s*Version:\s*\).*/\1$VERSION/" roxyapi.php
sed -i "s/const ROXYAPI_VERSION\s*=\s*'[^']*';/const ROXYAPI_VERSION = '$VERSION';/" roxyapi.php
sed -i "s/^Stable tag:.*$/Stable tag: $VERSION/" readme.txt
- name: Commit, tag, push
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
VERSION="${{ steps.bump.outputs.version }}"
git add .
git commit -m "release: v$VERSION"
git tag "v$VERSION"
git push --follow-tags
- name: Deploy to WordPress.org
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
generate-zip: true
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: roxyapi
VERSION: ${{ steps.bump.outputs.version }}
- name: Attach zip to GitHub release
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.bump.outputs.version }}
files: ${{ steps.deploy.outputs.zip-path }}
generate_release_notes: true
- name: No changes
if: steps.diff.outputs.changed == 'false' && github.event_name != 'workflow_dispatch'
run: echo "OpenAPI spec unchanged. Nothing to release."