Skip to content

Check for WordPress release #776

Check for WordPress release

Check for WordPress release #776

name: Check for WordPress release
on:
pull_request:
schedule:
- cron: '0 1 * * *'
jobs:
wp-release-check:
runs-on: ubuntu-latest
steps:
- name: Check release repository
run: |
echo "Collect and process json"
API_DATA=$(wget -cq "https://api.wordpress.org/core/version-check/1.7/" -O -)
RELEASE_DATA=$(echo ${API_DATA} | jq --compact-output '.["offers"] | limit( 1; .[] ) | {current}')
CURRENT_DATA=$(echo ${RELEASE_DATA} | grep -Eo -m1 '[[:digit:]]+\.[[:digit:]]+\.?[[:digit:]]*')
VERSION_DATA=$(echo ${API_DATA} | jq --compact-output '.["offers"] | map_values( {version} )')
WP49_VERSION=$(echo ${VERSION_DATA} | grep -Eo -m1 '[4]\.[9]\.[[:digit:]]+')
WP62_VERSION=$(echo ${VERSION_DATA} | grep -Eo -m1 '[6]\.[2]\.[[:digit:]]+')
echo "current_version=${CURRENT_DATA}" >> $GITHUB_ENV
echo "wp49_version=${WP49_VERSION}" >> $GITHUB_ENV
echo "wp62_version=${WP62_VERSION}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compare to Repository
run: |
MAX_WP_VERSION=$(grep 'max' v1/migration/index.php | head -n 1)
WP_VERSION=$(echo "${MAX_WP_VERSION}" | cut -d\' -f4)
WP49_VERSION=$(grep '$wp49' v1/migration/index.php | head -n 1 | grep -Eo -m1 '[4]+\.[9]+\.?[[:digit:]]*')
WP62_VERSION=$(grep '$wp62' v1/migration/index.php | head -n 1 | grep -Eo -m1 '[6]+\.[2]+\.?[[:digit:]]*')
if [ "${{ env.current_version }}" != "${WP_VERSION}" ]; then
echo "proceed=true" >> $GITHUB_ENV
NEW_WP_VERSION=$(sed "s|${WP_VERSION}|${{ env.current_version }}|" <<< ${MAX_WP_VERSION} )
sed -i "s|${MAX_WP_VERSION}|${NEW_WP_VERSION}|" v1/migration/index.php
PARTS=(`echo ${{ env.current_version}} | tr '.' ' '`)
MINOR_VERSION=$(echo ${PARTS[0]}.${PARTS[1]})
if [ '9' = ${PARTS[1]} ]; then
NEW_TEST_VERSION=$(echo $(( ${PARTS[0]} + 1 ))\\.0)
else
NEW_TEST_VERSION=$(echo ${PARTS[0]}\\.$(( ${PARTS[1]} + 1 )))
fi
NEW_TEST=$(echo "${NEW_TEST_VERSION}-(alpha" | sed 's|\\|\\\\|g')
CURRENT_TEST=$(echo "${MINOR_VERSION}-(alpha" | sed 's|\.|\\\\.|g')
sed -i "s|${CURRENT_TEST}|${NEW_TEST}|" v1/migration/index.php
if [ "${{ env.wp49_version }}" != "${WP49_VERSION}" ]; then
sed -i "s|wordpress-${WP49_VERSION}|wordpress-${{ env.wp49_version }}|" v1/migration/index.php
fi
if [ "${{ env.wp62_version }}" != "${WP62_VERSION}" ]; then
sed -i "s|wordpress-${WP62_VERSION}|wordpress-${{ env.wp62_version }}|" v1/migration/index.php
fi
else
echo "Migration from WordPress ${{ env.current_version }} is already supported"
echo "proceed=false" >> $GITHUB_ENV
fi
- name: Check for current Pull Request
if: ${{ env.proceed == 'true' }}
run: |
BRANCHES=$(git branch -a)
if [[ "$BRANCHES" = *wprelease/${{ env.current_version }}* ]]; then
echo 'Update API PR already exists'
echo "proceed=false" >> $GITHUB_ENV
fi
- name: Create Pull Request
id: createpr
uses: peter-evans/create-pull-request@v6
if: ${{ env.proceed == 'true' }}
with:
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
base: main
branch: wprelease/${{ env.current_version }}
commit-message: Update API for new WordPress ${{ env.current_version }} Release
title: Update API for WordPress ${{ env.current_version }} release
body: |
Update API Endpoint for migration
- Update supported release verison to ${{ env.current_version }}
See also https://core.trac.wordpress.org/query?milestone=${{ env.current_version }}