diff --git a/.github/workflows/classicpress-release.yml b/.github/workflows/classicpress-release.yml new file mode 100644 index 0000000..2151320 --- /dev/null +++ b/.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 + 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. diff --git a/.github/workflows/wordpress-release.yml b/.github/workflows/wordpress-release.yml new file mode 100644 index 0000000..6c48695 --- /dev/null +++ b/.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 + 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 }}