Skip to content

Commit 4c717bf

Browse files
authored
Merge pull request #305 from wpengine/chore-prep-plugins-for-composer-releases-to-packagist.org
chore: Automating plugin version for plugins
2 parents a33e4d1 + cae8466 commit 4c717bf

File tree

12 files changed

+162
-42
lines changed

12 files changed

+162
-42
lines changed

.github/workflows/e2e-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
cache: "npm"
8282

8383
- name: Install dependencies
84-
run: npm ci
84+
run: npm install
8585

8686
- name: Setup PHP with Cached Composer
8787
uses: ./.github/actions/setup-php-composer

plugins/hwp-previews/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
-----
1010

11-
[![Version](https://img.shields.io/badge/version-0.0.1-beta)]()
11+
[![Version](https://img.shields.io/github/v/release/wpengine/hwptoolkit?include_prereleases&label=previews&filter=%40wpengine%2Fhwp-previews-wordpress-plugin-*)](https://github.com/wpengine/hwptoolkit/releases)
1212
[![License](https://img.shields.io/badge/license-GPLv2%2B-green)]()
1313
![GitHub forks](https://img.shields.io/github/forks/wpengine/hwptoolkit?style=social)
1414
![GitHub stars](https://img.shields.io/github/stars/wpengine/hwptoolkit?style=social)
1515
[![Testing Integration](https://img.shields.io/github/check-runs/wpengine/hwptoolkit/main?checkName=hwp-previews%20codeception%20tests&label=Automated%20Tests)](https://github.com/wpengine/hwptoolkit/actions)
1616
[![Code Coverage](https://img.shields.io/badge/coverage-%3E95%25-brightgreen?label=Code%20Coverage)](https://github.com/wpengine/hwptoolkit/actions)
1717
[![Code Quality](https://img.shields.io/github/check-runs/wpengine/hwptoolkit/main?checkName=hwp-previews%20php%20code%20quality%20checks&label=Code%20Quality%20Checks)](https://github.com/wpengine/hwptoolkit/actions)
1818
[![End-to-End Tests](https://img.shields.io/github/check-runs/wpengine/hwptoolkit/main?checkName=hwp-previews%20Playwright%20E2E%20Tests&label=End-to-End%20Tests)](https://github.com/wpengine/hwptoolkit/actions)
19-
2019
-----
2120

2221

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
# Colors for output
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m' # No Color
11+
12+
# Get the version from package.json
13+
VERSION=$(node -p "require('./package.json').version")
14+
15+
if [ -z "$VERSION" ]; then
16+
echo -e "${RED}Error: Could not read version from package.json${NC}"
17+
exit 1
18+
fi
19+
20+
echo -e "${YELLOW}Syncing version ${VERSION} across all files...${NC}"
21+
22+
# Update composer.json
23+
if [ -f "composer.json" ]; then
24+
echo "Updating composer.json..."
25+
# Use sed to preserve original formatting (tabs/spaces)
26+
sed -i.bak -E "s/(\"version\":[[:space:]]*\")[^\"]*(\",?)/\1$VERSION\2/" composer.json && rm composer.json.bak
27+
echo -e "${GREEN}✓ Updated composer.json${NC}"
28+
else
29+
echo -e "${YELLOW}⚠ composer.json not found${NC}"
30+
fi
31+
32+
# Update readme.txt (WordPress style)
33+
if [ -f "readme.txt" ]; then
34+
echo "Updating readme.txt..."
35+
sed -i.bak -E "s/(Stable tag:|Version:)[[:space:]]*[0-9]+\.[0-9]+\.[0-9]+/\1 $VERSION/g" readme.txt && rm readme.txt.bak
36+
echo -e "${GREEN}✓ Updated readme.txt${NC}"
37+
else
38+
echo -e "${YELLOW}⚠ readme.txt not found${NC}"
39+
fi
40+
41+
# Update hwp-previews.php
42+
PLUGIN_FILE="hwp-previews.php"
43+
44+
if [ -f "$PLUGIN_FILE" ]; then
45+
echo "Updating main plugin file: $PLUGIN_FILE..."
46+
47+
# Update WordPress plugin header version (handles beta versions)
48+
sed -i.bak -E "s/(\* Version:[[:space:]]*)[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?/\1$VERSION/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak"
49+
50+
# Update HWP_PREVIEWS_VERSION define statement
51+
sed -i.bak -E "s/(define\([[:space:]]*['\"]HWP_PREVIEWS_VERSION['\"][[:space:]]*,[[:space:]]*['\"])[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?(['\"][[:space:]]*\))/\1$VERSION\3/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak"
52+
53+
echo -e "${GREEN}✓ Updated $PLUGIN_FILE${NC}"
54+
else
55+
echo -e "${YELLOW}$PLUGIN_FILE not found${NC}"
56+
fi
57+
58+
echo -e "${GREEN}✅ Version sync complete! All files updated to version ${VERSION}${NC}"
59+
echo -e "${YELLOW}Files will be staged by the workflow's 'git add .' command${NC}"``

plugins/hwp-previews/composer.json

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "hwp/previews",
2+
"name": "wpengine/previews",
33
"type": "wordpress-plugin",
44
"description": "A WordPress plugin for headless previews.",
55
"license": "GPL-2.0",
6-
"version": "0.0.1-beta",
6+
"version": "0.0.4",
77
"authors": [
88
{
99
"name": "WP Engine Headless OSS Development Team",
@@ -72,36 +72,35 @@
7272
"archive": {
7373
"name": "hwp-previews",
7474
"exclude": [
75-
"/.*",
76-
"bin",
77-
"docker",
78-
"docs",
79-
"phpstan",
80-
"phpcs",
81-
"plugin-build",
82-
"tests",
83-
"!vendor",
84-
"!vendor-prefixed",
85-
"/docker-compose.yml",
86-
"/phpstan.neon.dist",
87-
"/psalm.xml",
88-
"/phpcs.xml",
75+
"/.DS_Store",
76+
"/.docker/",
77+
"/.env.dist",
8978
"/ACTIONS_AND_FILTERS.md",
90-
"/phpcs-cache.json",
79+
"/TESTING.md",
9180
"/Thumbs.db",
81+
"/artifacts",
9282
"/auth.json",
93-
"/.DS_Store",
94-
".docker/",
95-
".env.dist",
96-
"c3.php",
97-
"codeception.dist.yml",
98-
"tests",
99-
"artifacts",
100-
"package.json",
101-
"package-lock.json",
102-
"node_modules/",
103-
"/TESTING.md",
104-
"/screenshots"
83+
"/bin",
84+
"/c3.php",
85+
"/codeception.dist.yml",
86+
"/docker",
87+
"/docker-compose.yml",
88+
"/docs",
89+
"/examples",
90+
"/node_modules",
91+
"/package-lock.json",
92+
"/package.json",
93+
"/phpcs",
94+
"/phpcs-cache.json",
95+
"/phpcs.xml",
96+
"/phpstan",
97+
"/phpstan.neon.dist",
98+
"/plugin-build",
99+
"/psalm.xml",
100+
"/screenshots",
101+
"/tests",
102+
"!vendor",
103+
"!vendor-prefixed"
105104
]
106105
},
107106
"autoload": {

plugins/hwp-previews/hwp-previews.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author: WPEngine Headless OSS Team
88
* Author URI: https://github.com/wpengine
99
* Update URI: https://github.com/wpengine/hwptoolkit
10-
* Version: 0.0.1-beta
10+
* Version: 0.0.4
1111
* Text Domain: hwp-previews
1212
* Domain Path: /languages
1313
* Requires at least: 6.0
@@ -67,7 +67,7 @@ function hwp_previews_init(): void {
6767
*/
6868
function hwp_previews_constants(): void {
6969
if ( ! defined( 'HWP_PREVIEWS_VERSION' ) ) {
70-
define( 'HWP_PREVIEWS_VERSION', '0.0.1-beta' );
70+
define( 'HWP_PREVIEWS_VERSION', '0.0.4' );
7171
}
7272

7373
if ( ! defined( 'HWP_PREVIEWS_PLUGIN_DIR' ) ) {

plugins/hwp-previews/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js",
99
"test:e2e:debug": "npm run test:e2e -- --debug",
10-
"wp-env": "wp-env"
10+
"wp-env": "wp-env",
11+
"version": "./scripts/sync-versions.sh"
1112
},
1213
"keywords": [],
1314
"author": "wpengine",

plugins/hwp-previews/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: GraphQL, Headless, Previews, WPGraphQL, React, Rest
44
Requires at least: 6.0
55
Tested up to: 6.8.1
66
Requires PHP: 7.4
7-
Stable tag: 0.0.1-beta
7+
Stable tag: 0.0.4
88
License: GPL-2.0
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
# Colors for output
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m' # No Color
11+
12+
# Get the version from package.json
13+
VERSION=$(node -p "require('./package.json').version")
14+
15+
if [ -z "$VERSION" ]; then
16+
echo -e "${RED}Error: Could not read version from package.json${NC}"
17+
exit 1
18+
fi
19+
20+
echo -e "${YELLOW}Syncing version ${VERSION} across all files...${NC}"
21+
22+
# Update composer.json
23+
if [ -f "composer.json" ]; then
24+
echo "Updating composer.json..."
25+
# Use sed to preserve original formatting (tabs/spaces)
26+
sed -i.bak -E "s/(\"version\":[[:space:]]*\")[^\"]*(\",?)/\1$VERSION\2/" composer.json && rm composer.json.bak
27+
echo -e "${GREEN}✓ Updated composer.json${NC}"
28+
else
29+
echo -e "${YELLOW}⚠ composer.json not found${NC}"
30+
fi
31+
32+
# Update readme.txt (WordPress style)
33+
if [ -f "readme.txt" ]; then
34+
echo "Updating readme.txt..."
35+
sed -i.bak -E "s/(Stable tag:|Version:)[[:space:]]*[0-9]+\.[0-9]+\.[0-9]+/\1 $VERSION/g" readme.txt && rm readme.txt.bak
36+
echo -e "${GREEN}✓ Updated readme.txt${NC}"
37+
else
38+
echo -e "${YELLOW}⚠ readme.txt not found${NC}"
39+
fi
40+
41+
# Update wp-graphql-webhooks.php
42+
PLUGIN_FILE="wp-graphql-webhooks.php"
43+
44+
if [ -f "$PLUGIN_FILE" ]; then
45+
echo "Updating main plugin file: $PLUGIN_FILE..."
46+
47+
# Update WordPress plugin header version (handles beta versions)
48+
sed -i.bak -E "s/(\* Version:[[:space:]]*)[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?/\1$VERSION/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak"
49+
50+
# Update WPGRAPHQL_WEBHOOKS_VERSION define statement
51+
sed -i.bak -E "s/(define\([[:space:]]*['\"]WPGRAPHQL_WEBHOOKS_VERSION['\"][[:space:]]*,[[:space:]]*['\"])[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?(['\"][[:space:]]*\))/\1$VERSION\3/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak"
52+
53+
echo -e "${GREEN}✓ Updated $PLUGIN_FILE${NC}"
54+
else
55+
echo -e "${YELLOW}$PLUGIN_FILE not found${NC}"
56+
fi
57+
58+
echo -e "${GREEN}✅ Version sync complete! All files updated to version ${VERSION}${NC}"
59+
echo -e "${YELLOW}Files will be staged by the workflow's 'git add .' command${NC}"``

plugins/wp-graphql-webhooks/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "wpengine/wp-graphql-webhooks",
33
"description": "Headless webhooks for WPGraphQL",
44
"type": "library",
5-
"license": "GPL-3.0-or-later",
5+
"license": "GPL-2.0",
6+
"version": "0.0.2",
67
"authors": [
78
{
89
"name": "WP Engine Headless OSS Development Team",
@@ -101,6 +102,7 @@
101102
"/bin",
102103
"/wp-graphql-webhooks",
103104
"/composer.lock",
105+
"/examples",
104106
"/phpstan.neon.dist",
105107
"/README.md"
106108
]

plugins/wp-graphql-webhooks/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"private": true,
55
"description": "Webhooks solution for WordPress",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"version": "./scripts/sync-versions.sh"
89
},
910
"keywords": [],
1011
"author": "wpengine",
@@ -16,4 +17,4 @@
1617
"@wordpress/jest-console": "^8.26.0",
1718
"@wordpress/scripts": "^30.19.0"
1819
}
19-
}
20+
}

0 commit comments

Comments
 (0)