Giter VIP home page Giter VIP logo

Comments (3)

mattyrob avatar mattyrob commented on June 20, 2024

I've been experimenting with bash scripting and regex and have the following as a potential starting point to fix the 3 issues raised about the last attempted code, specifically these issues were:

  • The current substitution command will lead to invalid replacements
    over time since it isn't limited to the specific place in the file that
    should be edited.
  • The 'other' versions array indicating which beta/RC releases of
    WordPress should be allowed is not updated.
  • This action probably does not correctly handle "5.9" vs "5.9.0" in
    major WP versions.

The code below hopefully makes the substitution more specific, it handles the 'other' versions more specifically and it also handles the WP release versioning better. It may well be clunky and I expected more improvements can be made but posting here so there is a record and starting point.

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_DATA=$(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)
           echo ${MAX_WP_VERSION} > ./max_wp_version.txt
           WP_VERSION=$(echo "${MAX_WP_VERSION}" | grep -Eo -m1 '[[:digit:]]\.[[:digit:]]\.?[[:digit:]]*')
           if [ ${{ env.current_version }} != ${WP_VERSION} ]; then
             sed -i "s|${WP_VERSION}|${{ env.current_version}}|" ./max_wp_version.txt
             NEW_WP_VERSION=$(cat ./max_wp_version.txt)
             sed -i "s|${MAX_WP_VERSION}|${NEW_WP_VERSION}|" ./v1/migration/index.php
             PARTS=(`echo ${{ env.current_version}} | tr '.' ' '`)
             if [ -z $PARTS[3] ]; then
               NEW_PATCH_RELEASE=$(echo ${PARTS[1]}.${PARTS[2]}.1)
             else
               NEW_PATCH_RELEASE=$(echo ${PARTS[1]}.${PARTS[2]}.$(( ${PARTS[3]} + 1 )))
             fi
             if [ 9 = ${PARTS[2]} ]; then
               NEW_RELEASE=$(echo $(( ${PARTS[1]} + 1 )).0)
             else
               NEW_RELEASE=$(echo ${PARTS[1]}.$(( ${PARTS[2]} + 1 )))
             fi
             PATCH_RC_VERSION=$(grep -Eo -m1 "(#\^[[:digit:]]+\\\.[[:digit:]]+\\\.[[:digit:]]+)-\(alpha" ./v1/migration/index.php)
             RC_VERSION=$(grep -Eo -m1 "(#\^[[:digit:]]+\\\.[[:digit:]]+)-\(alpha" ./v1/migration/index.php)
             sed -i "s|${PATCH_RC_VERSION}|${NEW_PATCH_RELEASE}|" ./v1/migration/index.php
             sed -i "s|${RC_VERSION}|${NEW_RELEASE}|" ./v1/migration/index.php
       - name: Create Pull Request
         id: createpr
         uses: peter-evans/create-pull-request@v3
         with:
           committer: GitHub <[email protected]>
           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 }}

from classicpress-apis.

bahiirwa avatar bahiirwa commented on June 20, 2024

@mattyrob is there a place for us to test this?

from classicpress-apis.

mattyrob avatar mattyrob commented on June 20, 2024

@bahiirwa It is possible to test step wise in in Linux command line. With higher confidence in what we have we can create and tweak the workflow later if needed.

from classicpress-apis.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.