Skip to content

Commit 48286c1

Browse files
authored
Merge pull request #1206 from cloudinary/uat
Release process GH Action
2 parents 63f3b71 + 111318f commit 48286c1

6 files changed

Lines changed: 152 additions & 1446 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: CI
22

33
on:
44
push:
5+
branches: [ develop, master ]
6+
workflow_call:
57
pull_request:
68

79
jobs:
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Deploy to WordPress.org Repository
2+
3+
on:
4+
5+
# The action will run when a release or a pre-release is created.
6+
#
7+
# In case of a pre-release, the action will not commit to WP.org (dry-run). However, it will still
8+
# create a zip file and upload it to the release. Note that a pre-release (release candidate)
9+
# should not be changed to a release but rather a new release should be created.
10+
#
11+
# The "prereleased" type will not trigger for pre-releases published from draft releases, but
12+
# the "published" type will trigger. Since we want a workflow to run when stable and pre-releases
13+
# publish, we subscribe to "published" instead of "released" and "prereleased".
14+
#
15+
# See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#release
16+
release:
17+
types: [ published ]
18+
19+
# Allows running the workflow manually (e.g. against a branch or tag) without publishing a
20+
# real GitHub release, so the pipeline can be exercised safely. Defaults to a dry-run.
21+
workflow_dispatch:
22+
inputs:
23+
dry_run:
24+
description: 'Skip the actual WP.org SVN commit (still builds, verifies, and uploads a zip artifact)'
25+
type: boolean
26+
default: true
27+
28+
jobs:
29+
lint_and_test:
30+
uses: ./.github/workflows/ci.yml
31+
secrets: inherit
32+
33+
deploy_to_wp_repository:
34+
needs: lint_and_test
35+
name: Deploy to WP.org
36+
runs-on: ubuntu-latest
37+
permissions:
38+
contents: write
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Setup Node
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version-file: '.nvmrc'
48+
cache: 'npm'
49+
50+
- name: Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: '8.3'
54+
tools: composer:v2
55+
56+
- name: Get Composer cache directory
57+
id: composer-cache
58+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
59+
60+
- name: Cache Composer packages
61+
uses: actions/cache@v4
62+
with:
63+
path: ${{ steps.composer-cache.outputs.dir }}
64+
key: ${{ runner.os }}-php-${{ hashFiles( 'composer.lock' ) }}
65+
restore-keys: ${{ runner.os }}-php-
66+
67+
# Install dependencies.
68+
- name: Install NPM dependencies
69+
run: npm ci
70+
71+
- name: Install Composer dependencies
72+
run: composer install --no-dev
73+
74+
# Build.
75+
- name: Build
76+
run: npm run build
77+
78+
- name: Prepare build directory
79+
run: npx grunt prepare
80+
81+
# Ensure the version in the .version file matches the tag of the release.
82+
# Skipped for manual runs, which may not be run against a release tag.
83+
- name: Verify version matches tag
84+
if: github.event_name == 'release'
85+
run: |
86+
TAG="${GITHUB_REF_NAME#v}"
87+
FILE_VERSION=$(cat .version | tr -d '[:space:]')
88+
if [ "$TAG" != "$FILE_VERSION" ]; then
89+
echo "::error::Tag $TAG does not match .version $FILE_VERSION"
90+
exit 1
91+
fi
92+
93+
- name: WordPress Plugin Deploy
94+
# This is used to get the zip-path later.
95+
id: deploy
96+
uses: 10up/action-wordpress-plugin-deploy@stable
97+
with:
98+
generate-zip: true
99+
# In case of a pre-release, do not commit to WP.org. Manual runs default to a dry-run too.
100+
dry-run: ${{ github.event_name == 'release' && github.event.release.prerelease || inputs.dry_run }}
101+
102+
env:
103+
BUILD_DIR: 'build'
104+
SLUG: 'cloudinary-image-management-and-manipulation-in-the-cloud-cdn'
105+
# Use secrets to authenticate with WP.org.
106+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
107+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
108+
109+
- name: Upload release asset
110+
if: github.event_name == 'release'
111+
uses: softprops/action-gh-release@v2
112+
with:
113+
files: ${{ steps.deploy.outputs.zip-path }}

.release-it.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,18 @@ Files included in the release package are defined in the `gruntfile.js` under th
111111

112112
### Deployment to WordPress.org
113113

114-
1. Tag a release from the `master` branch on GitHub.
114+
Deployment is automated via the `Deploy to WordPress.org Repository` GitHub Actions workflow (`.github/workflows/deploy-to-wp-org.yml`):
115115

116-
2. Run `npm run deploy` to deploy the version referenced in the `cloudinary.php` file of the current branch.
116+
1. Bump the version in `.version` on `master` (this is what gets checked against the release tag, and what `readme.txt`/`cloudinary.php` are stamped with during the build).
117117

118-
3. Run `npm run deploy-assets` to deploy just the WP.org plugin assets such as screenshots, icons and banners.
118+
2. Create and publish a GitHub Release from `master`, with a tag matching that version (e.g. `3.3.4` or `v3.3.4`). Publishing the release triggers the workflow, which builds the plugin, deploys it to the WP.org SVN repository, and attaches the built zip to the release.
119+
120+
- Marking the release as a **pre-release** runs the same workflow in dry-run mode: it builds and verifies everything but skips the actual SVN commit, which is the safe way to test a release without shipping it to WP.org.
121+
- The workflow can also be run manually from the Actions tab (`workflow_dispatch`) against any branch/tag, defaulting to a dry-run, to exercise the pipeline without publishing a GitHub release at all.
122+
123+
3. If you need to deploy from a local machine instead (e.g. as a fallback), run `npm run deploy`, which builds and runs `grunt deploy` using SVN credentials configured locally.
124+
125+
4. Run `npm run deploy-assets` to deploy just the WP.org plugin assets such as screenshots, icons and banners.
119126

120127
## End-to-end testing
121128

0 commit comments

Comments
 (0)