|
| 1 | +name: Bump WordPress Tested up to |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + plugin: |
| 7 | + type: string |
| 8 | + description: 'Plugin slug (leave empty for all plugins)' |
| 9 | + required: false |
| 10 | + |
| 11 | +jobs: |
| 12 | + prepare-matrix: |
| 13 | + name: Prepare plugins matrix |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + matrix: ${{ steps.set-matrix.outputs.plugins }} |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Configure plugin matrix |
| 22 | + id: set-matrix |
| 23 | + env: |
| 24 | + PLUGIN_SLUG: ${{ inputs.plugin }} |
| 25 | + run: | |
| 26 | + PLUGINS=$(jq -r '.plugins' plugins.json) |
| 27 | + if [[ -n "$PLUGIN_SLUG" ]]; then |
| 28 | + if echo $PLUGINS | jq -e '.[] | select(. == "'$PLUGIN_SLUG'")' > /dev/null; then |
| 29 | + PLUGINS="[ \"$PLUGIN_SLUG\" ]" |
| 30 | + else |
| 31 | + echo "::error::Plugin '$PLUGIN_SLUG' not found in plugins.json" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + fi |
| 35 | + echo "::notice::Updating plugins: $(echo ${PLUGINS[@]})" |
| 36 | + echo "plugins=$(echo $PLUGINS | jq -c .)" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + update-compatibility: |
| 39 | + name: Update "Tested up to" value for ${{ matrix.plugin }} |
| 40 | + needs: prepare-matrix |
| 41 | + runs-on: ubuntu-latest |
| 42 | + env: |
| 43 | + PLUGIN_SLUG: ${{ matrix.plugin }} |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + plugin: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }} |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Download WordPress.org readme |
| 52 | + run: | |
| 53 | + # Download the current readme.txt from WordPress.org |
| 54 | + curl -sSL --retry 3 --retry-delay 5 --retry-all-errors --fail -o /tmp/wp-org-readme.txt "https://plugins.svn.wordpress.org/$PLUGIN_SLUG/trunk/readme.txt" |
| 55 | + if [ $? -ne 0 ]; then |
| 56 | + echo "::error::Could not fetch readme.txt from WordPress.org for $PLUGIN_SLUG" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Extract "Tested up to" version from repository |
| 61 | + id: extract-tested-up-to |
| 62 | + run: | |
| 63 | + LOCAL_TESTED_UP_TO=$(grep -E "^Tested up to:" "./plugins/$PLUGIN_SLUG/readme.txt" | awk -F ': +' '{print $2}') |
| 64 | + if [ -z "$LOCAL_TESTED_UP_TO" ]; then |
| 65 | + echo "::error::Unable to parse Tested up to version from repository readme.txt" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | +
|
| 69 | + echo "version=$LOCAL_TESTED_UP_TO" >> $GITHUB_OUTPUT |
| 70 | +
|
| 71 | + - name: Prepare and update readme.txt |
| 72 | + env: |
| 73 | + LOCAL_TESTED_UP_TO: ${{ steps.extract-tested-up-to.outputs.version }} |
| 74 | + run: | |
| 75 | + # Replace local readme.txt with WordPress.org version, updating only the "Tested up to" line. |
| 76 | + cp /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" |
| 77 | + sed -i -E 's/^(Tested up to:[[:space:]]*).+/\1'"$LOCAL_TESTED_UP_TO"'/' "./plugins/$PLUGIN_SLUG/readme.txt" |
| 78 | +
|
| 79 | + # Show the diff of what's being updated. |
| 80 | + echo "Changes made to readme.txt:" |
| 81 | + diff -u /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" || true |
| 82 | +
|
| 83 | + - name: Push to WordPress.org |
| 84 | + uses: 10up/action-wordpress-plugin-asset-update@stable |
| 85 | + env: |
| 86 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 87 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 88 | + SLUG: ${{ matrix.plugin }} |
| 89 | + SKIP_ASSETS: true |
| 90 | + IGNORE_OTHER_FILES: true |
0 commit comments