From 4fb74256a0ff5b71f834f0661d0f4eaf26673cd3 Mon Sep 17 00:00:00 2001 From: Michelle Blanchette <33374343+MichelleBlanchette@users.noreply.github.com> Date: Sun, 10 Dec 2023 16:13:15 -0500 Subject: [PATCH] =?UTF-8?q?GitHub=20Action=20=E2=80=93=20Publish=20Release?= =?UTF-8?q?=20(#203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * drafting github action for publishing new releases * update bundle script to export zip file abspath in GitHub Actions * only run phpcs when PHP files are updated * improve entire folder exclusions * attempt to fix grep compatibility, attempt artifact upload * fix artifact name extra zip suffix, attempt dry run wporg publish * rn exclusions list to standard distignore filename * finalize publish release workflow events --- exclude.lst => .distignore | 12 +++++++++-- .github/workflows/phpcs.yml | 5 ++++- .github/workflows/publish.yml | 39 +++++++++++++++++++++++++++++++++++ build_cleanup.sh | 2 +- bundle.sh | 31 +++++++++++++++++++++++++--- completionist.php | 2 +- 6 files changed, 83 insertions(+), 8 deletions(-) rename exclude.lst => .distignore (61%) create mode 100644 .github/workflows/publish.yml diff --git a/exclude.lst b/.distignore similarity index 61% rename from exclude.lst rename to .distignore index 77229bcb..54e572eb 100644 --- a/exclude.lst +++ b/.distignore @@ -3,16 +3,24 @@ completionist/*.log completionist/*.map completionist/*.sh completionist/*.DS_Store -completionist/.git* +completionist/.gitignore +completionist/.github/* +completionist/.github +completionist/.git/* +completionist/.git +completionist/.wordpress-org/* completionist/.wordpress-org -completionist/exclude.lst +completionist/.distignore completionist/composer.json completionist/composer.lock completionist/node_modules/* +completionist/node_modules completionist/package-lock.json completionist/package.json completionist/phpcs.xml completionist/assets/styles/scss/* +completionist/assets/styles/scss completionist/src/components/* +completionist/src/components completionist/src/*.js completionist/src/*.jsx diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index e51d3bbb..da5158e9 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,6 +1,9 @@ name: PHPCS Check -on: [pull_request] +on: + pull_request: + paths: + - '**.php' jobs: phpcs: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..1a77eff6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish Release + +on: + push: + tags: + - "v*" + - "!v**-rc.*" + +jobs: + tag: + name: New release + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Build - Install + run: ./build_install.sh + shell: bash + + - name: Bundle Package + run: ./bundle.sh + shell: bash + + - name: Upload ZIP File + uses: actions/upload-artifact@v3 + with: + name: ${{ env.PTC_PLUGIN_ZIP_FILE_BASENAME }} + path: ${{ env.PTC_PLUGIN_ZIP_FILE }} + + - name: Publish WordPress Plugin Release + uses: 10up/action-wordpress-plugin-deploy@stable + with: + dry-run: true + generate-zip: false + env: + SVN_USERNAME: ${{ secrets.WPORG_SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.WPORG_SVN_PASSWORD }} diff --git a/build_cleanup.sh b/build_cleanup.sh index 223e63aa..5b24aa7f 100755 --- a/build_cleanup.sh +++ b/build_cleanup.sh @@ -1,5 +1,5 @@ #!/bin/bash -for PATTERN in $(cat "exclude.lst") +for PATTERN in $(cat ".distignore") do rm -rf "../"${PATTERN} done diff --git a/bundle.sh b/bundle.sh index cb9aeb8c..e7e402a3 100755 --- a/bundle.sh +++ b/bundle.sh @@ -1,8 +1,33 @@ #!/bin/bash +# Determine package values. + PLUGIN_SLUG=$( basename `pwd` ) -VERSION=$(grep -Eio 'Version:\s*[0-9\.]+' "${PLUGIN_SLUG}.php" | grep -Eo '[0-9\.]+') +VERSION=$(grep -Eio 'Version:\s*[0-9]+\.[0-9]+\.[0-9]+(\-rc\.[0-9]+)?' "${PLUGIN_SLUG}.php" | grep -Eio '[0-9]+\.[0-9]+\.[0-9]+(\-rc\.[0-9]+)?') + +# Create the plugin package. + +pushd .. + +PLUGIN_ZIP_FILE=$( pwd )/"${PLUGIN_SLUG}-${VERSION}.zip" + +zip -rT9X "${PLUGIN_ZIP_FILE}" "${PLUGIN_SLUG}" --exclude @"${PLUGIN_SLUG}"/.distignore + +popd + +# Maybe export variables for GitHub Action. + +if [ -n "$GITHUB_ENV" ]; then + echo "PTC_PLUGIN_ZIP_FILE_BASENAME=$( basename -s '.zip' "$PLUGIN_ZIP_FILE" )" >> "$GITHUB_ENV" + echo "PTC_PLUGIN_ZIP_FILE=${PLUGIN_ZIP_FILE}" >> "$GITHUB_ENV" + echo "Exported GitHub ENV variables." +else + echo "Did not set \$GITHUB_ENV variables." +fi + +# Final notes. -cd .. -zip -rT9X "${PLUGIN_SLUG}-${VERSION}.zip" "${PLUGIN_SLUG}" --exclude @"${PLUGIN_SLUG}"/exclude.lst +echo +echo "!! Finished bundling plugin package: ${PLUGIN_ZIP_FILE}" +echo diff --git a/completionist.php b/completionist.php index 3ac8f56f..b99222a1 100644 --- a/completionist.php +++ b/completionist.php @@ -10,7 +10,7 @@ * Plugin Name: Completionist – Asana for WordPress * Plugin URI: https://purpleturtlecreative.com/completionist/ * Description: Manage, pin, automate, and display Asana tasks in relevant areas of your WordPress admin and website frontend. - * Version: 4.0.0 + * Version: 4.0.0-rc.5 * Requires PHP: 7.2 * Requires at least: 5.0.0 * Tested up to: 6.4.2