From 1208bf3ae7fb2738f393d6a87237c58e8f64769c Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Fri, 1 Dec 2023 17:48:04 +0000 Subject: [PATCH] Add github workflow to deploy to WP Plugin repo (#234) --- .distignore | 39 ++++++++++ .github/workflows/deploytowp.yml | 43 +++++++++++ .github/workflows/upateassets.yml | 17 +++++ .../banner-1544x500.png | Bin {assets => .wordpress-org}/banner-772x250.png | Bin {assets => .wordpress-org}/icon-128x128.png | Bin {assets => .wordpress-org}/icon-256x256.png | Bin bin/release.sh | 67 ------------------ bin/readme.txt => readme.txt | 2 +- 9 files changed, 100 insertions(+), 68 deletions(-) create mode 100644 .distignore create mode 100644 .github/workflows/deploytowp.yml create mode 100644 .github/workflows/upateassets.yml rename {assets => .wordpress-org}/banner-1544x500.png (100%) rename {assets => .wordpress-org}/banner-772x250.png (100%) rename {assets => .wordpress-org}/icon-128x128.png (100%) rename {assets => .wordpress-org}/icon-256x256.png (100%) delete mode 100644 bin/release.sh rename bin/readme.txt => readme.txt (97%) diff --git a/.distignore b/.distignore new file mode 100644 index 0000000..21bcda8 --- /dev/null +++ b/.distignore @@ -0,0 +1,39 @@ +# A set of files you probably don't want in your WordPress.org distribution +.distignore +.editorconfig +.git +.gitignore +.gitlab-ci.yml +.travis.yml +.DS_Store +.wordpress-org +composer.json +composer.lock +book.json +Thumbs.db +behat.yml +bitbucket-pipelines.yml +bin +.circleci/config.yml +docs +.github +Gruntfile.js +package.json +package-lock.json +phpunit.xml +phpunit.xml.dist +phpunit-multisite.xml.dist +multisite.xml +multisite.xml.dist +.phpcs.xml +phpcs.xml +.phpcs.xml.dist +phpcs.xml.dist +README.md +wp-cli.local.yml +yarn.lock +tests +node_modules +*.sql +*.tar.gz +*.zip \ No newline at end of file diff --git a/.github/workflows/deploytowp.yml b/.github/workflows/deploytowp.yml new file mode 100644 index 0000000..9c86ddb --- /dev/null +++ b/.github/workflows/deploytowp.yml @@ -0,0 +1,43 @@ +name: Deploy to WordPress.org +on: + push: + tags: + - "**" +jobs: + tag: + name: New tag + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: composer + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer vendor directory + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install PHP Dependencies + run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader --no-interaction + + - name: WordPress Plugin Deploy + uses: 10up/action-wordpress-plugin-deploy@stable + env: + SLUG: ${{ secrets.SLUG }} + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} diff --git a/.github/workflows/upateassets.yml b/.github/workflows/upateassets.yml new file mode 100644 index 0000000..1830635 --- /dev/null +++ b/.github/workflows/upateassets.yml @@ -0,0 +1,17 @@ +name: Asset update +on: + push: + branches: + - master +jobs: + master: + name: Push to main + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: WordPress.org asset update + uses: 10up/action-wordpress-plugin-asset-update@stable + env: + SLUG: ${{ secrets.SLUG }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} diff --git a/assets/banner-1544x500.png b/.wordpress-org/banner-1544x500.png similarity index 100% rename from assets/banner-1544x500.png rename to .wordpress-org/banner-1544x500.png diff --git a/assets/banner-772x250.png b/.wordpress-org/banner-772x250.png similarity index 100% rename from assets/banner-772x250.png rename to .wordpress-org/banner-772x250.png diff --git a/assets/icon-128x128.png b/.wordpress-org/icon-128x128.png similarity index 100% rename from assets/icon-128x128.png rename to .wordpress-org/icon-128x128.png diff --git a/assets/icon-256x256.png b/.wordpress-org/icon-256x256.png similarity index 100% rename from assets/icon-256x256.png rename to .wordpress-org/icon-256x256.png diff --git a/bin/release.sh b/bin/release.sh deleted file mode 100644 index 3389be9..0000000 --- a/bin/release.sh +++ /dev/null @@ -1,67 +0,0 @@ -# release.sh -# -# Takes a tag to release, and syncs it to WordPress.org - -TAG=$1 - -PLUGIN="rest-api-oauth1" -TMPDIR=/tmp/rest-api-oauth1-release-svn -PLUGINDIR="$PWD" -PLUGINSVN="https://plugins.svn.wordpress.org/$PLUGIN" - -# Fail on any error -set -e - -# Is the tag valid? -if [ -z "$TAG" ] || ! git rev-parse "$TAG" > /dev/null; then - echo "Invalid tag. Make sure you tag before trying to release." - exit 1 -fi - -if [[ $VERSION == "v*" ]]; then - # Starts with an extra "v", strip for the version - VERSION=${TAG:1} -else - VERSION="$TAG" -fi - -if [ -d "$TMPDIR" ]; then - # Wipe it clean - rm -r "$TMPDIR" -fi - -# Ensure the directory exists first -mkdir "$TMPDIR" - -# Grab an unadulterated copy of SVN -svn co "$PLUGINSVN/trunk" "$TMPDIR" > /dev/null - -# Extract files from the Git tag to there -git archive --format="zip" -0 "$TAG" | tar -C "$TMPDIR" -xf - - -# Switch to build dir -cd "$TMPDIR" - -# Run build tasks -sed -e "s/{{TAG}}/$VERSION/g" < "$PLUGINDIR/bin/readme.txt" > readme.txt - -# Remove special files -rm ".gitignore" -rm "composer.json" -rm "book.json" -rm -r "bin" -rm -r "docs" -rm -r ".github" - -# Add any new files -svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add - -# Pause to allow checking -echo "About to commit $VERSION. Double-check $TMPDIR to make sure everything looks fine." -read -p "Hit Enter to continue." - -# Commit the changes -svn commit -m "Tag $VERSION" - -# tag_ur_it -svn copy "$PLUGINSVN/trunk" "$PLUGINSVN/tags/$VERSION" -m "Tag $VERSION" diff --git a/bin/readme.txt b/readme.txt similarity index 97% rename from bin/readme.txt rename to readme.txt index 0919889..2b0c7ef 100644 --- a/bin/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: json, rest, api, rest-api Requires at least: 4.4 Requires PHP: 5.4 Tested up to: 6.4 -Stable tag: {{TAG}} +Stable tag: 0.4.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html