Skip to content

Commit

Permalink
Merge pull request #3 from 2ndkauboy/fix/readme-name
Browse files Browse the repository at this point in the history
Add the possibility to use a README.md instead of a readme.txt file
  • Loading branch information
helen authored Oct 16, 2019
2 parents c3ede1e + 5c4e8f8 commit 72690bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# WordPress.org Plugin Readme/Assets Update

This Action commits any `readme.txt` and WordPress.org-specific assets changes in your specified branch to the WordPress.org plugin repository if no other changes have been made since the last deployment to WordPress.org. This is useful for updating things like screenshots or `Tested up to` separately from functional changes, provided your Git branching methodology avoids changing anything else in the specified branch between functional releases. It is **highly recommended** that you use a stable branch where you only merge readme/asset commits in between larger functional merges that only occur when preparing for a release (often implemented as `master` vs. `develop`).
This Action commits any readme and WordPress.org-specific assets changes in your specified branch to the WordPress.org plugin repository if no other changes have been made since the last deployment to WordPress.org. This is useful for updating things like screenshots or `Tested up to` separately from functional changes, provided your Git branching methodology avoids changing anything else in the specified branch between functional releases. It is **highly recommended** that you use a stable branch where you only merge readme/asset commits in between larger functional merges that only occur when preparing for a release (often implemented as `master` vs. `develop`).

Because the WordPress.org plugin repository shows information from `readme.txt` in the specified `Stable tag`, this Action also attempts to parse out the stable tag from `readme.txt` and deploy to there as well as `trunk`. If your stable tag is `trunk` or a tag that does not exist in the `tags` subfolder, it will skip that part of the update and only update `trunk` and/or `assets`.
Because the WordPress.org plugin repository shows information from the readme in the specified `Stable tag`, this Action also attempts to parse out the stable tag from your readme and deploy to there as well as `trunk`. If your stable tag is `trunk` or a tag that does not exist in the `tags` subfolder, it will skip that part of the update and only update `trunk` and/or `assets`.

**Important note:** If your development process leads to a situation where `master` (or other specified branch) only contains changes to `readme.txt` or `assets` since the last sync to the plugin directory and those changes are in preparation for the next release, those changes will go live and potentially be misleading to users. Usage of this Action assumes a fairly traditional Git methodology that involves merging all changes to `master` when functional changes are ready and that this seemingly unlikely situation will therefore not happen in your repo; there are no safeguards against syncing changes based on readme/asset content, as that cannot be predicted.
**Important note:** If your development process leads to a situation where `master` (or other specified branch) only contains changes to the readme or assets directory since the last sync to the plugin directory and those changes are in preparation for the next release, those changes will go live and potentially be misleading to users. Usage of this Action assumes a fairly traditional Git methodology that involves merging all changes to `master` when functional changes are ready and that this seemingly unlikely situation will therefore not happen in your repo; there are no safeguards against syncing changes based on readme/asset content, as that cannot be predicted.

### ☞ This Action is meant to be used in tandem with our [WordPress.org Plugin Deploy Action](https://github.com/10up/action-wordpress-plugin-deploy)

Expand All @@ -17,8 +17,9 @@ Because the WordPress.org plugin repository shows information from `readme.txt`
[Secrets are set in your repository settings](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables). They cannot be viewed once stored.

### Optional environment variables
* `SLUG` - defaults to the repository name, customizable in case your WordPress repository has a different slug or is capitalized differently.
* `ASSETS_DIR` - defaults to `.wordpress-org`, customizable for other locations of WordPress.org plugin repository-specific assets that belong in the top-level `assets` directory (the one on the same level as `trunk`)
* `SLUG` - defaults to the respository name, customizable in case your WordPress repository has a different slug or is capitalized differently.
* `ASSETS_DIR` - defaults to `.wordpress-org`, customizable for other locations of WordPress.org plugin repository-specific assets that belong in the top-level `assets` directory (the one on the same level as `trunk`).
* `README_NAME` - defaults to `readme.txt`, customizable in case you use `README.md` instead, which is now quietly supported in the WordPress.org plugin repository.

## Example Workflow File
```yml
Expand Down
15 changes: 10 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ if [[ -z "$ASSETS_DIR" ]]; then
fi
echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR"

if [[ -z "$README_NAME" ]]; then
README_NAME="readme.txt"
fi
echo "ℹ︎ README_NAME is $README_NAME"

SVN_URL="http://plugins.svn.wordpress.org/${SLUG}/"
SVN_DIR="/github/svn-${SLUG}"

Expand Down Expand Up @@ -100,17 +105,17 @@ if [[ -z $(svn stat) ]]; then
# Check if there is more than just the readme.txt modified in trunk
# The leading whitespace in the pattern is important
# so it doesn't match potential readme.txt in subdirectories!
elif svn stat trunk | grep -qvi ' trunk/readme.txt$'; then
elif svn stat trunk | grep -qvi " trunk/$README_NAME$"; then
echo "🛑 Other files have been modified; changes not deployed"
exit 1
fi

# Readme also has to be updated in the .org tag
echo "➤ Preparing stable tag..."
STABLE_TAG=$(grep -m 1 "^Stable tag:" "$TMP_DIR/readme.txt" | tr -d '\r\n' | awk -F ' ' '{print $NF}')
STABLE_TAG=$(grep -m 1 "^Stable tag:" "$TMP_DIR/$README_NAME" | tr -d '\r\n' | awk -F ' ' '{print $NF}')

if [ -z "$STABLE_TAG" ]; then
echo "ℹ︎ Could not get stable tag from readme.txt";
if [[ -z "$STABLE_TAG" ]]; then
echo "ℹ︎ Could not get stable tag from $README_NAME";
HAS_STABLE=1
else
echo "ℹ︎ STABLE_TAG is $STABLE_TAG"
Expand All @@ -119,7 +124,7 @@ else
svn update --set-depth infinity "tags/$STABLE_TAG"

# Not doing the copying in SVN for the sake of easy history
rsync -c "$TMP_DIR/readme.txt" "tags/$STABLE_TAG/"
rsync -c "$TMP_DIR/$README_NAME" "tags/$STABLE_TAG/"
else
echo "ℹ︎ Tag $STABLE_TAG not found"
fi
Expand Down

0 comments on commit 72690bd

Please sign in to comment.