|
|
||
|---|---|---|
| .github | ||
| src | ||
| .gitignore | ||
| action.yml | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
WP Self-Host Updater Generator
A GitHub Action for WordPress plugin and theme developers to enable self-hosted updates directly from GitHub. This Action simplifies the process of self-hosting your plugins by:
- Generating and commititing a JSON file based on the
readme.txt.
- The
JSONfile will be used by plugin/theme to check updates. - The
JSONfile will be created onwp-dist/data-json.
- Creating a new release with a
.zipdistribution file.
- The
.zipfile follows the folder structure requires by WordPress. - You can define folders or files to be excluded from the
.zipfile. To more details check the section Preparing the Distribution File: Excluding Paths/Files from the ZIP
Use this action to streamline the self-hosting process for your WordPress plugins and themes.
How to Use
This repository provides everything you need to the GitHub Action to work seamlessly and the "server" side of the self-host working as expected. However, this is just the “server” side of the solution. To fully enable self-hosted updates, you’ll need to integrate a simple PHP file into your plugin or theme. This file will manages communication with the JSON and release files generated by this Action directly from your repository.
-
Quick Start Guide: Explore our guide How to Self-Host WordPress Plugins on Github and Deliver Updates for an easy-to-follow walkthrough of the entire self-hosting setup. It covers integrating this GitHub Action with the required PHP file in your plugin to ensure seamless updates.
-
Required Integration: Check out WP Self-Host Updater Checker to get the required PHP file to add in your plugin/theme. This is an essential step to enable the fully self-hosted update mechanism.
Requirements
Before using this GitHub Action, ensure the following:
readme.txtFile: A valid WordPress plugin readme file must exist in the root of your repository.- GitHub Token: The repository must allow write access for the GitHub Actions token. You need to define the necessary permissions in your workflow file (details below).
Workflow Configuration
To use this Action, create a new workflow file in your repository:
- Navigate to
.github/workflows/. - Create a new file, e.g.,
generate-dist-file.yaml. - Add the following content to the file:
name: Generate Dist File for Plugin
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
generate-json-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: main
- name: Run WP Self-Host Update JSON Generator
uses: eduardovillao/wp-self-host-updater-generator@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Important Notes
- Permissions: Ensure that
contents: writeis defined in the workflow file for theGITHUB_TOKEN. - Repository Checkout: The first step must check out the repository, specifying the branch where the JSON file will be committed (
mainormaster). - Trigger Events: Currently, the Action supports triggers only when a tag is created. Future versions may support additional trigger events.
Preparing the Distribution File: Excluding Paths/Files from the ZIP
To exclude specific files or directories from the .zip file generated during the release process, configure a .gitattributes file in your repository. This file ensures that unnecessary files are omitted from the export.
Here’s an example of a .gitattributes file:
# Exclude the wp-dist folder and its contents
wp-dist/ export-ignore
# Exclude hidden files and directories
.* export-ignore
# Exclude Git metadata
.git/ export-ignore
# Exclude local configuration files
*.env export-ignore
*.log export-ignore
# Exclude development and editor-specific settings
.vscode/ export-ignore
.idea/ export-ignore
*.iml export-ignore
# Exclude unnecessary documentation
*.md export-ignore
# Exclude test files and directories
tests/ export-ignore
*.spec.js export-ignore
*.test.js export-ignore
# Exclude CI configuration files
.github/ export-ignore
.gitlab-ci.yml export-ignore
# Exclude build configurations and dependencies
node_modules/ export-ignore
package-lock.json export-ignore
yarn.lock export-ignore