Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create PR via workflow when ClassicPress is released #38

Merged
merged 12 commits into from Feb 3, 2022
60 changes: 60 additions & 0 deletions .github/workflows/classicpress-release.yml
@@ -0,0 +1,60 @@
name: Check for ClassicPress 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_URL=$(wget -cq "https://api.github.com/repos/ClassyBot/ClassicPress-nightly/releases?per_page=3" -O - | jq -r '.[].html_url' | grep '%2Bnightly\.' | head -n1)
CURRENT_VERSION=$(echo "${RELEASE_URL}" | sed 's#.*/##; s#%2B.*##')
RELEASE_DATE=$(echo "${RELEASE_URL: -8}")
if [ -z "$CURRENT_VERSION" ] || [ -z "$RELEASE_DATE" ]; then
echo "Determining release info FAILED!"
exit 1
fi
if [[ "$CURRENT_VERSION" = *-* ]]; then
echo "Latest nightly version is beta/RC/etc: $CURRENT_VERSION"
echo "Not proceeding!"
echo "proceed=false" >> $GITHUB_ENV
else
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_ENV
echo "release_date=${RELEASE_DATE}" >> $GITHUB_ENV
echo "proceed=true" >> $GITHUB_ENV
fi

- name: Checkout repository
uses: actions/checkout@v2
if: ${{ env.proceed == 'true' }}

- name: Compare to Repository
if: ${{ env.proceed == 'true' }}
run: |
API_VERSION=$(grep '^\$build_version =' v1/migration/index.php | cut -d\' -f2)
if [ "${{ env.current_version }}" != "${API_VERSION}" ]; then
sed -ri "s#^\\\$build_version =.*\$#\$build_version = '${{ env.current_version }}';#" v1/migration/index.php
sed -ri "s#^\\\$build_date =.*\$#\$build_date = '${{ env.release_date }}';#" v1/migration/index.php
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: master
branch: release/${{ env.current_version }}
commit-message: Update API for ClassicPress ${{ env.current_version }} release
title: Update API for ClassicPress ${{ env.current_version }} release
body: |
Update API endpoint for migration
- Update release version to ${{ env.current_version }}
- Update release date to ${{ env.release_date }}
See also https://github.com/ClassicPress/ClassicPress-APIs/pull/38.
38 changes: 38 additions & 0 deletions .github/workflows/wordpress-release.yml
@@ -0,0 +1,38 @@
name: Check for WordPress release

on:
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 '.[] | limit( 1; .[] ) | {current}')
CURRENT_VERSION=$(echo "${RELEASE_DATA}" | grep -Eo -m1 '[[:digit:]]\.[[:digit:]]\.[[:digit:]]')
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v2
- name: Compare to Repository
run: |
MAX_WP_VERSION=$(grep -Eo -m1 "'max'\s*=>\s'([[:digit:]]\.[[:digit:]]\.[[:digit:]]*)'" ./v1/migration/index.php)
WP_VERSION=$(echo "${MAX_WP_VERSION}" | grep -Eo -m1 '[[:digit:]]\.[[:digit:]]\.[[:digit:]]')
if [ ${{ env.current_version }} != ${WP_VERSION} ]; then
sed "s|${WP_VERSION}|${{ env.current_version }}|" ./v1/migration/index.php
fi
- name: Create Pull Request
id: createpr
uses: peter-evans/create-pull-request@v3
with:
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: release/${{ env.current_version }}
commit-message: Update API for new WordPressPress Release
title: Update API for ${{ env.current_version }} release
body: |
Update API Endpoint
- Update endpoint to release ${{ env.current_version }}
- Update release date to ${{ env.release_date }}