Skip to content

Commit 75a675c

Browse files
committed
Updated release branch script to run composer package updates if a valid composer and package file exists for the plugin.
1 parent edfa54d commit 75a675c

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

.github/workflows/create-release-branch.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ jobs:
7171
# Apply version bumps from changesets
7272
pnpm changeset version
7373
74-
# Run version script for the plugin if it exists
75-
if [ -f "plugins/${{ steps.plugin.outputs.slug }}/package.json" ]; then
76-
echo "Checking for version script in plugins/${{ steps.plugin.outputs.slug }}/package.json"
74+
# Only run if both package.json and composer.json exist for the plugin
75+
if [ -f "plugins/${{ steps.plugin.outputs.slug }}/package.json" ] && [ -f "plugins/${{ steps.plugin.outputs.slug }}/composer.json" ]; then
76+
echo "Both package.json and composer.json found for ${{ steps.plugin.outputs.slug }}"
77+
78+
# Run version script for the plugin if it exists
7779
if cat "plugins/${{ steps.plugin.outputs.slug }}/package.json" | grep -q '"version".*:'; then
7880
echo "Running version script for ${{ steps.plugin.outputs.slug }}"
7981
cd "plugins/${{ steps.plugin.outputs.slug }}"
@@ -82,8 +84,38 @@ jobs:
8284
else
8385
echo "No version script found for ${{ steps.plugin.outputs.slug }}"
8486
fi
87+
88+
# Get new version from plugin's package.json
89+
NEW_VERSION=$(jq -r '.version' "plugins/${{ steps.plugin.outputs.slug }}/package.json")
90+
91+
# Build the download URL
92+
# e.g. https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fhwp-previews-wordpress-plugin-0.0.5/hwp-previews.zip
93+
# Get the "name" field from plugin's package.json and URL encode it
94+
PKG_NAME=$(jq -r '.name' "plugins/${{ steps.plugin.outputs.slug }}/package.json")
95+
ENCODED_PKG_NAME=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "$PKG_NAME")
96+
97+
# Format is [github-repository]/releases/download/[encoded-package-name]-[version]/[plugin-slug].zip
98+
RELEASE_URL="https://github.com/wpengine/hwptoolkit/releases/download/${ENCODED_PKG_NAME}-${NEW_VERSION}/${{ steps.plugin.outputs.slug }}.zip"
99+
100+
# Get plugin description from plugin's composer.json
101+
DESCRIPTION=$(jq -r '.description // empty' "plugins/${{ steps.plugin.outputs.slug }}/composer.json")
102+
103+
# Run the composer package update script
104+
# Get the "name" field from plugin's composer.json
105+
COMPOSER_NAME=$(jq -r '.name' "plugins/${{ steps.plugin.outputs.slug }}/composer.json")
106+
if [ -n "$NEW_VERSION" ] && [ -n "$RELEASE_URL" ] && [ -n "$COMPOSER_NAME" ] && [ -n "$DESCRIPTION" ]; then
107+
.github/scripts/update_composer_package.sh "$NEW_VERSION" "$RELEASE_URL" "$COMPOSER_NAME" "$DESCRIPTION"
108+
else
109+
echo "Error: Missing required values for update_composer_package.sh"
110+
echo "NEW_VERSION: $NEW_VERSION"
111+
echo "RELEASE_URL: $RELEASE_URL"
112+
echo "COMPOSER_NAME: $COMPOSER_NAME"
113+
echo "DESCRIPTION: $DESCRIPTION"
114+
exit 1
115+
fi
116+
85117
else
86-
echo "No package.json found for plugin ${{ steps.plugin.outputs.slug }}"
118+
echo "package.json and/or composer.json not found for plugin ${{ steps.plugin.outputs.slug }}. Skipping version and composer update steps."
87119
fi
88120
89121
# Configure git

0 commit comments

Comments
 (0)