Skip to content

Commit 1f86f19

Browse files
committed
feat: add interactive release CLI for OpenFields plugin
- Introduced `release.ts` script for managing plugin releases. - Enhanced README with detailed usage instructions for build and release processes. - Updated build commands to use Vite and TypeScript. - Implemented SVN deployment and GitHub release functionalities. - Added dry-run option for safe testing of release actions.
1 parent af38458 commit 1f86f19

File tree

6 files changed

+820
-158
lines changed

6 files changed

+820
-158
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ wp-content/
3939
wordpress/
4040
.wp-env-home/
4141

42+
# SVN (WordPress.org deployment)
43+
.svn-repo/
44+
4245
# Misc
4346
*.zip
4447
*.tar.gz

RELEASES.md

Lines changed: 81 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,133 @@
1-
# 🚀 OpenFields - Quick Release Guide
1+
# Release Guide
22

3-
**For releasing OpenFields to users**
3+
How to release Codeideal Open Fields to users.
44

55
---
66

7-
## The Super Simple Release Process
7+
## Quick Release (Interactive CLI)
88

9-
### Step 1: Update Version
109
```bash
11-
cd openfields
12-
pnpm version patch # or 'minor' for new features, 'major' for big changes
10+
pnpm release
1311
```
1412

15-
This updates `package.json` automatically.
13+
This opens an interactive prompt where you choose:
14+
- **WordPress.org** (SVN → trunk + tagged version)
15+
- **GitHub** (git tag → Actions → Release page)
16+
- **Both**
1617

17-
### Step 2: Push with Tag
18-
```bash
19-
git push origin main --tags
20-
```
21-
22-
### Done! 🎉
23-
24-
**GitHub Actions automatically:**
25-
- ✅ Builds the plugin
26-
- ✅ Creates a ZIP file
27-
- ✅ Uploads to [Releases page](https://github.com/novincode/openfields/releases)
28-
- ✅ Generates release notes
29-
30-
---
31-
32-
## For Users
33-
34-
They download from the [Releases page](https://github.com/novincode/openfields/releases):
35-
36-
1. Click the latest release
37-
2. Download `openfields-X.X.X.zip`
38-
3. Upload to WordPress → Plugins → Add New → Upload
39-
4. Click Install & Activate
40-
41-
**No coding needed!** 👍
18+
That's it. The CLI handles building, versioning, zipping, and deploying.
4219

4320
---
4421

45-
## Version Bumping Guide
22+
## CLI Flags (Non-Interactive)
4623

4724
```bash
48-
# Bug fixes & small improvements → patch
49-
pnpm version patch # v0.1.0 → v0.1.1
50-
51-
# New features, backwards compatible → minor
52-
pnpm version minor # v0.1.1 → v0.2.0
53-
54-
# Breaking changes → major
55-
pnpm version major # v0.2.0 → v1.0.0
25+
pnpm release:svn # WordPress.org only
26+
pnpm release:github # GitHub only
27+
pnpm release:all # Both targets
28+
pnpm release:dry # Dry-run (build + preview, no commits)
5629
```
5730

5831
---
5932

60-
## What GitHub Actions Does
33+
## Step-by-Step: New Version Release
6134

62-
### On Every Tag Push
35+
### 1. Bump the version
6336

64-
**File:** `.github/workflows/release.yml`
37+
```bash
38+
pnpm version patch # 0.3.0 → 0.3.1 (bug fixes)
39+
pnpm version minor # 0.3.0 → 0.4.0 (new features)
40+
pnpm version major # 0.3.0 → 1.0.0 (breaking changes)
41+
```
6542

66-
1. Checks out code
67-
2. Installs Node dependencies
68-
3. Runs `pnpm run build:plugin:release`
69-
4. Creates GitHub Release
70-
5. Uploads ZIP file to release
43+
This updates `package.json` automatically and creates a git commit + tag.
7144

72-
**Result:** Your plugin is instantly downloadable! 🎁
45+
### 2. Push code to GitHub
7346

74-
### On Every Push
47+
```bash
48+
git push origin main
49+
```
7550

76-
**File:** `.github/workflows/build.yml`
51+
### 3. Release
7752

78-
1. Runs TypeScript type checking
79-
2. Runs ESLint linting
80-
3. Builds the plugin
81-
4. Saves build artifacts
53+
```bash
54+
pnpm release
55+
```
8256

83-
**Result:** Catches errors early! ✅
57+
Select your targets and confirm. Done.
8458

8559
---
8660

87-
## Testing Before Release
61+
## What Happens Under the Hood
8862

89-
```bash
90-
# Build locally
91-
pnpm run build:plugin:release
63+
### Build Phase (always runs first)
64+
1. Syncs version from `package.json``codeideal-open-fields.php`
65+
2. Builds admin React/TypeScript app via Vite
66+
3. Creates distributable ZIP in `dist/`
9267

93-
# Test in WordPress
94-
# Upload dist/openfields-X.X.X.zip
95-
# Test in admin
68+
### WordPress.org SVN Deploy
69+
1. Updates local SVN working copy (`.svn-repo/`)
70+
2. Syncs all plugin files to `trunk/`
71+
3. Creates a version tag via `svn cp trunk tags/X.Y.Z`
72+
4. Commits everything to `https://plugins.svn.wordpress.org/codeideal-open-fields/`
73+
5. Update appears on wordpress.org within ~15 minutes
9674

97-
# If all good, push tags:
98-
git tag v0.2.0
99-
git push origin --tags
100-
```
75+
### GitHub Release
76+
1. Creates an annotated git tag `vX.Y.Z`
77+
2. Pushes tag to origin
78+
3. GitHub Actions (`.github/workflows/release.yml`) builds and creates a Release with the ZIP attached
10179

10280
---
10381

104-
## Common Commands
82+
## Configuration
10583

106-
```bash
107-
# See what changed
108-
git status
109-
git diff
110-
111-
# Make a commit
112-
git add .
113-
git commit -m "feat: Add new feature"
114-
115-
# Update version
116-
pnpm version patch
117-
118-
# Push to GitHub (triggers release)
119-
git push origin main --tags
120-
121-
# Check release status
122-
# Visit: https://github.com/novincode/openfields/actions
123-
```
84+
| Item | Location |
85+
|---|---|
86+
| SVN credentials | `.env` (`SVN_PASSWORD=...`) |
87+
| SVN username | `shayancode` |
88+
| SVN working copy | `.svn-repo/` (git-ignored) |
89+
| SVN repository | `https://plugins.svn.wordpress.org/codeideal-open-fields/` |
90+
| Plugin version source | `package.json``version` |
91+
| Release script | `scripts/release.ts` |
92+
| Build script | `scripts/build.sh` |
93+
| GitHub Actions | `.github/workflows/release.yml` |
12494

12595
---
12696

12797
## Troubleshooting
12898

129-
### GitHub Actions Failed?
130-
- Check https://github.com/novincode/openfields/actions
131-
- Click failed workflow to see error
132-
- Common issues:
133-
- Build errors → `pnpm run build` locally first
134-
- Type errors → `pnpm run type-check` locally
135-
- Lint errors → `pnpm run lint:fix` locally
99+
### SVN commit fails with "Access forbidden"
100+
- Check your SVN password at https://profiles.wordpress.org/me/profile/edit/group/3/?screen=svn-password
101+
- Ensure `.env` has the correct `SVN_PASSWORD`
102+
- Username is `shayancode` (case-sensitive)
136103

137-
### Need to Redo a Release?
138-
```bash
139-
# Delete tag locally
140-
git tag -d v0.2.0
104+
### Plugin not showing on WordPress.org after deploy
105+
- WordPress.org rebuilds ZIPs after each SVN commit — can take up to 15 minutes
106+
- Check https://wordpress.org/plugins/codeideal-open-fields/ after waiting
141107

142-
# Delete on GitHub
143-
git push origin --delete v0.2.0
144-
145-
# Create again
146-
pnpm version patch
147-
git push origin main --tags
148-
```
108+
### GitHub Actions failed
109+
- Check https://github.com/novincode/openfields/actions
110+
- Common issues: build errors, type errors, lint errors
111+
- Test locally first: `pnpm release:dry`
149112

150-
### Want to Test Workflow?
113+
### Need to redo a release
151114
```bash
152-
# Build locally
153-
pnpm run build:plugin:release
115+
# Delete the git tag
116+
git tag -d v0.3.1
117+
git push origin --delete v0.3.1
154118

155-
# Check files
156-
ls -la dist/
119+
# Fix the issue, then re-release
120+
pnpm release
157121
```
158122

159123
---
160124

161125
## Release Checklist
162126

163-
Before pushing:
164-
165-
- [ ] `git pull` - Get latest changes
166-
- [ ] Code review of your changes
167-
- [ ] `pnpm run build:plugin:release` - Build successfully
168-
- [ ] Test in WordPress locally
169-
- [ ] `pnpm version patch` - Update version
170-
- [ ] `git push origin main --tags` - Push tag
171-
- [ ] Wait for Actions to complete (1-2 min)
172-
- [ ] Check [Releases page](https://github.com/novincode/openfields/releases)
173-
- [ ] Download ZIP to verify
174-
175-
---
176-
177-
## Need Help?
178-
179-
- **Build errors?** → See [docs/BUILD.md](./docs/BUILD.md)
180-
- **Contributing?** → See [CONTRIBUTING.md](./CONTRIBUTING.md)
181-
- **Documentation?** → See [docs/INDEX.md](./docs/INDEX.md)
182-
- **GitHub Actions?** → Check `.github/workflows/`
183-
184-
---
185-
186-
That's it! Simple, automated, and professional. 🎉
187-
188-
Made with ❤️ by the OpenFields team
127+
- [ ] `git pull origin main` — get latest
128+
- [ ] Review your changes
129+
- [ ] `pnpm release:dry` — dry-run to verify everything builds
130+
- [ ] `pnpm version patch` (or minor/major) — bump version
131+
- [ ] `pnpm release` — deploy
132+
- [ ] Verify on [WordPress.org](https://wordpress.org/plugins/codeideal-open-fields/)
133+
- [ ] Verify on [GitHub Releases](https://github.com/novincode/openfields/releases)

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"format": "prettier --write \"admin/src/**/*.{ts,tsx,css}\"",
1919
"test": "vitest",
2020
"test:ui": "vitest --ui",
21+
"release": "tsx scripts/release.ts",
22+
"release:svn": "tsx scripts/release.ts --svn",
23+
"release:github": "tsx scripts/release.ts --github",
24+
"release:all": "tsx scripts/release.ts --all",
25+
"release:dry": "tsx scripts/release.ts --dry --all",
2126
"wp-env": "wp-env",
2227
"wp-env:start": "wp-env start",
2328
"wp-env:stop": "wp-env stop",
@@ -57,6 +62,7 @@
5762
},
5863
"devDependencies": {
5964
"@types/node": "^22.10.0",
65+
"@types/prompts": "^2.4.9",
6066
"@types/react": "^18.3.0",
6167
"@types/react-dom": "^18.3.0",
6268
"@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -69,10 +75,13 @@
6975
"eslint-config-prettier": "^9.1.0",
7076
"eslint-plugin-react": "^7.37.0",
7177
"eslint-plugin-react-hooks": "^5.0.0",
78+
"picocolors": "^1.1.1",
7279
"postcss": "^8.4.49",
7380
"prettier": "^3.4.0",
81+
"prompts": "^2.4.2",
7482
"tailwindcss": "^3.4.15",
7583
"tailwindcss-animate": "^1.0.7",
84+
"tsx": "^4.21.0",
7685
"typescript": "^5.7.0",
7786
"vite": "^6.0.0",
7887
"vitest": "^2.1.0"

0 commit comments

Comments
 (0)