Skip to content

Commit 27edf10

Browse files
authored
refactor: reusable WP.org release workflow (#226)
1 parent b9ca882 commit 27edf10

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Release to WordPress.org.
2+
# Requires the calling workflow to run reusable-release.yml first (which uploads release artifacts).
3+
name: Release to WordPress.org
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
plugin-name:
9+
description: 'WordPress.org plugin slug. Defaults to the repository name.'
10+
required: false
11+
type: string
12+
default: ''
13+
secrets:
14+
WP_ORG_USERNAME:
15+
required: true
16+
WP_ORG_PASSWORD:
17+
required: true
18+
19+
jobs:
20+
release-wporg:
21+
name: Release to WordPress.org
22+
runs-on: ubuntu-latest
23+
env:
24+
PLUGIN_NAME: ${{ inputs.plugin-name || github.event.repository.name }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version-file: '.nvmrc'
35+
cache: 'npm'
36+
37+
- name: Install dependencies
38+
run: npm ci --legacy-peer-deps
39+
40+
- name: Download release artifacts
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: release-artifacts
44+
path: release/
45+
46+
- name: Verify release artifacts
47+
run: |
48+
if [ ! -d "release/$PLUGIN_NAME" ]; then
49+
echo "::error::release/$PLUGIN_NAME not found. The release job must produce this directory via release:archive."
50+
exit 1
51+
fi
52+
53+
- name: Release to WordPress.org
54+
env:
55+
WP_ORG_USERNAME: ${{ secrets.WP_ORG_USERNAME }}
56+
WP_ORG_PASSWORD: ${{ secrets.WP_ORG_PASSWORD }}
57+
WP_ORG_PLUGIN_NAME: ${{ env.PLUGIN_NAME }}
58+
run: ./node_modules/newspack-scripts/release-wporg.sh

.github/workflows/reusable-release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,11 @@ jobs:
5151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5252
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5353
run: npm run release
54+
55+
- name: Upload release artifacts
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: release-artifacts
59+
path: release/
60+
if-no-files-found: ignore
61+
retention-days: 1

0 commit comments

Comments
 (0)