Skip to content

Commit

Permalink
[LOC-6169] Fetch plugin updates from WPE servers (#29)
Browse files Browse the repository at this point in the history
* feat: get plugin updates from WPE

Adapted from the sample code at https://github.com/wpengine/plugin-updater.

* ci: comment out wp-svn usage

This plugin can no longer be published on WP.org due to blocked access.

We'll just lint in Circle for now on the non-master branch.

* chore: fix plugin_basename for updater

This plugin has a different entry point.

* chore: add npm run zip script

To make it easier to package a zip for production.

* chore: bump version to 1.1.3, add changelog

* chore: ignore phpcs warning for dirname
  • Loading branch information
nickcernis authored Oct 15, 2024
1 parent c217d1c commit 344136c
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 148 deletions.
252 changes: 126 additions & 126 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
wp-svn: studiopress/[email protected]
# orbs:
# wp-svn: studiopress/[email protected]

commands:
install_dependencies:
Expand All @@ -16,48 +16,48 @@ commands:
command: |
[ ! -d "/tmp/artifacts" ] && mkdir /tmp/artifacts &>/dev/null
set_verision_variable:
description: "Set the VERSION environment variable"
steps:
- run:
command: |
echo "export VERSION=$(grep 'Version:' /tmp/src/genesis-simple-menus.php | awk -F: '{print $2}' | sed 's/^\s//')" >> ${BASH_ENV}
show_pwd_info:
description: "Show information about the current directory"
steps:
- run: pwd
- run: ls -lash

svn_setup:
description: "Setup SVN"
steps:
- run: echo "export SLUG=$(grep '@package' /tmp/src/genesis-simple-menus.php | awk -F ' ' '{print $3}' | sed 's/^\s//')" >> ${BASH_ENV}
- run: svn co https://plugins.svn.wordpress.org/${SLUG} --depth=empty .
- run: svn up trunk
- run: svn up tags --depth=empty
- run: find ./trunk -not -path "./trunk" -delete
- run: cp -r /tmp/src/. ./trunk
- run: svn propset svn:ignore -F ./trunk/.svnignore ./trunk

svn_add_changes:
description: "Add changes to SVN"
steps:
- run:
command: if [[ ! -z $(svn st | grep ^\!) ]]; then svn st | grep ^! | awk '{print " --force "$2}' | xargs -0r svn rm; fi
- run: svn add --force .

svn_create_tag:
description: "Create a SVN tag"
steps:
- set_verision_variable
- run: svn cp trunk tags/${VERSION}

svn_commit:
description: "Commit changes to SVN"
steps:
- set_verision_variable
- run: svn ci -m "Tagging ${VERSION} from Github" --no-auth-cache --non-interactive --username "${SVN_USERNAME}" --password "${SVN_PASSWORD}"
# set_verision_variable:
# description: "Set the VERSION environment variable"
# steps:
# - run:
# command: |
# echo "export VERSION=$(grep 'Version:' /tmp/src/genesis-simple-menus.php | awk -F: '{print $2}' | sed 's/^\s//')" >> ${BASH_ENV}

# show_pwd_info:
# description: "Show information about the current directory"
# steps:
# - run: pwd
# - run: ls -lash

# svn_setup:
# description: "Setup SVN"
# steps:
# - run: echo "export SLUG=$(grep '@package' /tmp/src/genesis-simple-menus.php | awk -F ' ' '{print $3}' | sed 's/^\s//')" >> ${BASH_ENV}
# - run: svn co https://plugins.svn.wordpress.org/${SLUG} --depth=empty .
# - run: svn up trunk
# - run: svn up tags --depth=empty
# - run: find ./trunk -not -path "./trunk" -delete
# - run: cp -r /tmp/src/. ./trunk
# - run: svn propset svn:ignore -F ./trunk/.svnignore ./trunk

# svn_add_changes:
# description: "Add changes to SVN"
# steps:
# - run:
# command: if [[ ! -z $(svn st | grep ^\!) ]]; then svn st | grep ^! | awk '{print " --force "$2}' | xargs -0r svn rm; fi
# - run: svn add --force .

# svn_create_tag:
# description: "Create a SVN tag"
# steps:
# - set_verision_variable
# - run: svn cp trunk tags/${VERSION}

# svn_commit:
# description: "Commit changes to SVN"
# steps:
# - set_verision_variable
# - run: svn ci -m "Tagging ${VERSION} from Github" --no-auth-cache --non-interactive --username "${SVN_USERNAME}" --password "${SVN_PASSWORD}"

executors:
base:
Expand Down Expand Up @@ -102,26 +102,26 @@ jobs:
- install_dependencies
- run: composer phpcs

deploy_svn_branch:
executor: base
working_directory: /tmp/artifacts
steps:
- attach_workspace:
at: /tmp
- svn_setup
- svn_add_changes
- svn_commit

deploy_svn_tag:
executor: base
working_directory: /tmp/artifacts
steps:
- attach_workspace:
at: /tmp
- svn_setup
- svn_create_tag
- svn_add_changes
- svn_commit
# deploy_svn_branch:
# executor: base
# working_directory: /tmp/artifacts
# steps:
# - attach_workspace:
# at: /tmp
# - svn_setup
# - svn_add_changes
# - svn_commit

# deploy_svn_tag:
# executor: base
# working_directory: /tmp/artifacts
# steps:
# - attach_workspace:
# at: /tmp
# - svn_setup
# - svn_create_tag
# - svn_add_changes
# - svn_commit

workflows:
version: 2
Expand All @@ -139,65 +139,65 @@ workflows:
branches:
ignore:
- master
- approval-for-deploy-tested-up-to-bump:
type: approval
requires:
- checks
filters:
tags:
ignore: /.*/
branches:
only: /^bump-tested-up-to.*/
- wp-svn/deploy-tested-up-to-bump:
context: genesis-svn
requires:
- approval-for-deploy-tested-up-to-bump

branch_deploy:
jobs:
- checkout:
filters:
branches:
only:
- master
- checks:
requires:
- checkout
filters:
branches:
only:
- master
- deploy_svn_branch:
context: genesis-svn
requires:
- checks
filters:
branches:
only:
- master

tag_deploy:
jobs:
- checkout:
filters:
tags:
only: /^\d+\.\d+\.\d+$/
branches:
ignore: /.*/
- checks:
requires:
- checkout
filters:
tags:
only: /^\d+\.\d+\.\d+$/
branches:
ignore: /.*/
- deploy_svn_tag:
context: genesis-svn
requires:
- checks
filters:
tags:
only: /^\d+\.\d+\.\d+$/
branches:
ignore: /.*/
# - approval-for-deploy-tested-up-to-bump:
# type: approval
# requires:
# - checks
# filters:
# tags:
# ignore: /.*/
# branches:
# only: /^bump-tested-up-to.*/
# - wp-svn/deploy-tested-up-to-bump:
# context: genesis-svn
# requires:
# - approval-for-deploy-tested-up-to-bump

# branch_deploy:
# jobs:
# - checkout:
# filters:
# branches:
# only:
# - master
# - checks:
# requires:
# - checkout
# filters:
# branches:
# only:
# - master
# - deploy_svn_branch:
# context: genesis-svn
# requires:
# - checks
# filters:
# branches:
# only:
# - master

# tag_deploy:
# jobs:
# - checkout:
# filters:
# tags:
# only: /^\d+\.\d+\.\d+$/
# branches:
# ignore: /.*/
# - checks:
# requires:
# - checkout
# filters:
# tags:
# only: /^\d+\.\d+\.\d+$/
# branches:
# ignore: /.*/
# - deploy_svn_tag:
# context: genesis-svn
# requires:
# - checks
# filters:
# tags:
# only: /^\d+\.\d+\.\d+$/
# branches:
# ignore: /.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Thumbs.db
.svn
node_modules/
vendor/
*.zip
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
7 changes: 7 additions & 0 deletions .svnignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
.gitignore
.gitattributes
.svnignore
.nvmrc
.circleci/
.DS_Store
composer.json
composer.lock
node_modules
package.json
package-lock.json
scripts/
*.zip
17 changes: 16 additions & 1 deletion genesis-simple-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

define( 'GENESIS_SIMPLE_MENU_SETTINGS_FIELD', 'genesis_simple_menu_settings' );
define( 'GENESIS_SIMPLE_MENU_VERSION', '1.1.2' );
define( 'GENESIS_SIMPLE_MENU_VERSION', '1.1.3' );
define( 'GENESIS_SIMPLE_MENU_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'GENESIS_SIMPLE_MENU_PLUGIN_URL', plugins_url( '', __FILE__ ) );

Expand Down Expand Up @@ -42,3 +42,18 @@ function genesis_simple_menus() {
* Initialize the object on `plugins_loaded`.
*/
add_action( 'plugins_loaded', array( Genesis_Simple_Menus(), 'init' ) );

/**
* Initialize checking of plugin updates from WP Engine.
*/
function genesis_simple_menus_check_for_upgrades() {
$properties = array(
'plugin_slug' => 'genesis-simple-menus',
// phpcs:ignore
'plugin_basename' => plugin_basename( dirname( __FILE__ ) . '/simple-menu.php' ),
);

require_once __DIR__ . '/includes/class-genesis-simple-menus-plugin-updater.php';
new Genesis_Simple_Menus_Plugin_Updater( $properties );
}
add_action( 'admin_init', 'genesis_simple_menus_check_for_upgrades' );
Loading

0 comments on commit 344136c

Please sign in to comment.