Update API for ClassicPress 2.0.0 release #648
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check for WordPress release | |
on: | |
pull_request: | |
schedule: | |
- cron: '0 1 * * *' | |
jobs: | |
release-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check release repository | |
run: | | |
echo "Collect and process json" | |
RELEASE_DATA=$(wget -cq "https://api.wordpress.org/core/version-check/1.7/" -O - | jq --compact-output '.["offers"] | limit( 1; .[] ) | {current}') | |
CURRENT_DATA=$(echo ${RELEASE_DATA} | grep -Eo -m1 '[[:digit:]]+\.[[:digit:]]+\.?[[:digit:]]*') | |
echo "current_version=${CURRENT_DATA}" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
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) | |
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 | |
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@v3 | |
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 }} |