|
71 | 71 | # Apply version bumps from changesets |
72 | 72 | pnpm changeset version |
73 | 73 |
|
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 |
77 | 79 | if cat "plugins/${{ steps.plugin.outputs.slug }}/package.json" | grep -q '"version".*:'; then |
78 | 80 | echo "Running version script for ${{ steps.plugin.outputs.slug }}" |
79 | 81 | cd "plugins/${{ steps.plugin.outputs.slug }}" |
|
82 | 84 | else |
83 | 85 | echo "No version script found for ${{ steps.plugin.outputs.slug }}" |
84 | 86 | 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 | +
|
85 | 117 | 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." |
87 | 119 | fi |
88 | 120 |
|
89 | 121 | # Configure git |
|
0 commit comments