-
Notifications
You must be signed in to change notification settings - Fork 0
Plugin Deployment
This guide is about deploying plugins that utilize Sake for deployment to the WooCommerce.com marketplace, the WordPress plugins directory, or simply hosted on GitHub.
Sake assumes plugins will follow semantic versioning (SemVer).
When deploying, you'll determine what the version should be (patch, minor, or major) based on the changelog.
The concepts described in the Semantic Versioning specification will be applied as closely as is possible to versioning plugins. The specification refers largely to a software's "public API", which doesn't necessarily apply to every plugin, but we can consider the admin/frontend interface to be a form of "public API" as well. Some highlights:
- Patch version Z (x.y.Z | x > 0) MUST be incremented if only backwards compatible bug fixes are introduced. A bug fix is defined as an internal change that fixes incorrect behavior.
- Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backwards compatible functionality is introduced to the public API. It MUST be incremented if any public API functionality is marked as deprecated. It MAY be incremented if substantial new functionality or improvements are introduced within the private code. It MAY include patch level changes. Patch version MUST be reset to 0 when minor version is incremented.
- Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API. It MAY include minor and patch level changes. Patch and minor version MUST be reset to 0 when major version is incremented.
- A pre-release version MAY be denoted by appending a dash and a series of dot separated identifiers immediately following the patch version. Identifiers MUST be comprised of only ASCII alphanumerics and dash [0-9A-Za-z-]. Pre-release versions satisfy but have a lower precedence than the associated normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
Point number 4 can be used to assign a plugin a provisional version number when performing ongoing development which will be part of a future commit of unknown size/version increment. This provisional version number shall be updated to a final version number prior to release.
An initial internal release candidate may be revisioned as a 0-leading number, ie 0.1 up until it is released, at which point all reference to the pre-release version shall be replaced with 1.0, except in the case where a pre-release plugin was written for and released to a client.
Any pre-release version numbers should be replaced with the final version number when deploying. This includes the changelog.txt entry, main plugin file header and optional version constant, as well as any @since
or other comment references or version comparison checks, or any other place in code.
Typically, all plugin deploys are done via Sake, but some may be done manually. The following section contains a description of the plugin release process, first with a pre-flight checklist:
- Ensure the changelog is completed with a list of changes and additions
- Ensure that the plugin has a development version in the changelog and main plugin file header / version constant
- Merge the plugin PR into master and delete the PR branch
- Ensure you're on
master
and pull changes inwc-plugins
and ensure your local copy is clean without any uncommitted changes - For automated deploys:
- For manual deploys:
Add these entries to your .bash_profile
(or .zprofile
if you're on zsh):
export GITHUB_USERNAME="yourusername"
export GITHUB_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export WC_CONSUMER_KEY="ck_xxxxxxx"
export WC_CONSUMER_SECRET="cs_xxxxxxxxx"
export WP_SVN_USER="SkyVerge"
export SAKE_PRE_RELEASE_PATH="~/path/to/pre-releases/folder/"
export SAKE_PRODUCTION_GITHUB_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export DEPLOY_DOCS="skyverge/wc-plugins-sales-docs"
Where
-
GITHUB_USERNAME
is the username associated with your GitHub account -
GITHUB_API_KEY
is your personal access token with 'gist', 'repo', and 'user' scopes. These can be generated on the Applications settings page. -
WC_CONSUMER_KEY
&WC_CONSUMER_SECRET
listed under the "WooCommerce API" entry in 1Password -
WP_SVN_USER
is the username used to commit plugin changes to the WordPress.org SVN repository. -
SAKE_PRE_RELEASE_PATH
is the path to the SkyVerge pre-releases folder. e.g.~/Dropbox (SkyVerge)/skyverge-prereleases
or${DROPBOX_PATH}/skyverge-prereleases/
if you had previously setDROPBOX_PATH
-
SAKE_PRODUCTION_GITHUB_API_KEY
is a personal access token withgist
,repo
, anduser
scopes for the WooCommerce mirror repositories. These can be generated on the Applications settings page. -
DEPLOY_DOCS
is the owner and name of the repository where Saké should create documentation issues. The default value above should work for all of our plugins.
Run composer install --no-dev
as a sanity check to confirm your vendor directory is clean. This can help to prevent errors during npx sake deploy
caused by uncommitted changes in the vendors directories (exussum12/coverage-checker has uncommitted changes
appears sometimes after using composer phpcs-diff
).
Open your favorite command line app and try:
cd /path/to/wc-plugins/<plugin-dir>
composer install --no-dev
Then, once you have set everything up as instructed above:
cd /path/to/wc-plugins/<plugin-dir>
npx sake deploy
Note: if you are deploying a compatibility release for a WC version that was not released yet (RC) or a release on top of such compatibility release, you can add the tested_up_to_wc_version
parameter to update the WC tested up to
header. For instance:
npx sake deploy --tested_up_to_wc_version=3.8.0
You will be prompted to select the plugin version that is to be deployed. The prompt will show you the latest changes and the current version. Use your arrow keys to select the best suited version and hit return to let Sake continue.
Once the release has gone through the main deploy process, you will be prompted to confirm you want to upload the final release zip to woocommerce.com:
Upload plugin to WooCommerce.com?
At this point, you should visit the plugin's mirror repo at github.com/woocommerce/{plugin-slug}
and view the single deploy commit, usually named something like Update {Plugin Name} to x.x.x
. Check the changes in that commit to confirm that there are no surprises, like files added or deleted that shouldn't have been. Once confirmed, you can confirm the prompt.
The plugin will be uploaded to WooCommerce.com! After that, it'll take around 5 minutes to become publicly available.
If the commit includes unexpected changes, you should decline the prompt to prevent the new version of the plugin from being uploaded to WooCommerce.com.
In that case, the new version doesn't go out, so we can remove the unexpected changes without bumping the patch version. We can delete the releases and tags from the repos and re-deploy:
- Delete the release and tag from the mirror repo
- Delete the release and tag from the wc-plugins repo
- Revert the versioning commit on the mirror repo
- Revert the versioning commit on the wc-plugins repo
After that, confirming you don't have any local changes, you can re-run the sake command.
For each plugin you deploy, you'll see a notification in #woocommerce Slack for the successful release. You should make sure and confirm that each deployed plugin gets a successful notification, and re-upload any plugins that fail.
- During deploy
-
Error: WC API: Sorry, you don't have permission to access this resource. (wccom_rest_cannot_manage_product)
- This usually indicates that you don't have theWC_CONSUMER_KEY
andWC_CONSUMER_SECRET
values defined in your environment.
-
- After deploy
-
virus!
- This usually means that their zip scanning failed for some reason, and that the plugin needs to be re-uploaded
-
Sometimes the product pages take extra time to update due to caching. If a new version is taking a long time to show up, you can check the list of versions in the marketplace admin to confirm all is well. If the new version is there, it'll eventually appear in the product pages.
To access the marketplace admin:
- Open an incognito window and go to https://woocommerce.com/my-account
- Log in using the WooCommerce Marketplace Admin password from 1Pass
- Click on "Vendor Dashboard" to see all of the plugins and their deployed versions
-
For each plugin, update date in changelog and Find & Replace the development version with the release version across all plugin files. It is a good idea to check for earlier development versions. For example, if the current dev. version is
1.2.1-dev.4
find and replace1.2.1-dev.4
,1.2.1-dev.3
,1.2.1-dev.2
, and1.2.1-dev.1
with '1.2.2' -
Update the date in the changelog
-
In Terminal:
# compile and zip the plugin cd /path/to/wc-plugins/<plugin-dir-name> npx sake zip
-
Test out the plugin in the
/build
directory. The easiest way is to symlink the plugins in this folder to a test WordPress site# stage all changes git add -A # commit changes git commit -m "Plugin Name: x.xx.x Versioning" # push changes git push # copy/pasta files to Woo repo and delete all unnecessary files. # commit in the Woo repo cd path/to/woocommerce/repo git add -A git commit -m "Update Plugin Name to x.xx.x" # create a release in the Woo repo tagged and titled with the version (x.xx.x) and paste in the changelog entries
Once a plugin has been finalized for release, the containing repository shall be tagged with the following format:
tag: woocommerce-plugin-name-1.0
message:
WooCommerce Plugin Name v1.0
changelog entries
Substituting the actual plugin name and version number of course. The git tag command would look like:
$ git tag -a woocommerce-plugin-name-1.0 558151a
Where 558151a
is the release commit if not HEAD. Tags must then be pushed to github with the following command:
$ git push --tags
- Tag version: woocommerce-plugin-name-1.0
- Select the target revision
- Release Title: WooCommerce Plugin Name v1.0
- Comment: Changelog entries
- Attach the plugin zip as the release binary