-
Notifications
You must be signed in to change notification settings - Fork 2
92 lines (82 loc) · 3.24 KB
/
deploy.yml
File metadata and controls
92 lines (82 loc) · 3.24 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
name: Deploy to WordPress.org
# Deliberate, human-gated deploys:
# • Publishing a GitHub Release (with a bare version tag, e.g. 1.0.3) builds
# the plugin and deploys trunk + that tag to the WordPress.org SVN repo,
# then attaches a built .zip to the Release.
# • The "Run workflow" button (workflow_dispatch) runs the SAME build and SVN
# checkout but, by default, performs a DRY RUN — it stops before committing
# to SVN so you can inspect the file diff in the logs before a real release.
on:
release:
types: [published]
workflow_dispatch:
inputs:
dry_run:
description: "Dry run (build + SVN checkout, no commit)"
type: boolean
default: true
tag:
description: "Version to deploy (only used for a non-dry-run manual deploy)"
type: string
required: false
permissions:
contents: write # needed to upload the .zip asset back to the Release
jobs:
deploy:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
tools: composer
- name: Build JS/CSS assets
run: |
npm ci
npm run build
- name: Generate production autoloader
# No third-party runtime deps — this just dumps the optimized PSR-4
# autoloader the plugin requires at runtime (vendor/autoload.php).
run: composer install --no-dev --optimize-autoloader --no-interaction
- name: Determine version
id: ver
# Always resolve a clean version (no slashes) so the SVN tag path is valid.
# Release: the published tag. Manual: the `tag` input, else the readme
# Stable tag (handy default for dry runs).
run: |
if [ "${{ github.event_name }}" = "release" ]; then
version="${{ github.event.release.tag_name }}"
elif [ -n "${{ inputs.tag }}" ]; then
version="${{ inputs.tag }}"
else
version="$(grep -i '^Stable tag:' readme.txt | sed -E 's/.*:[[:space:]]*//' | tr -d '[:space:]')"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Resolved version: $version"
- name: Deploy to WordPress.org
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
generate-zip: true
# Real deploy on Release publish; manual runs honor the dry_run input.
dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
# Repo name (github-release-posts-wordpress) differs from the .org slug,
# so SLUG must be set explicitly.
SLUG: auto-release-posts-for-github
VERSION: ${{ steps.ver.outputs.version }}
- name: Attach built .zip to the Release
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.deploy.outputs.zip-path }}