wp-self-host-updater-generator/README.md

112 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

2024-12-23 03:24:45 -03:00
# WP Self-Host Updater Generator
2024-12-22 22:10:14 -03:00
2024-12-30 22:43:39 -03:00
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:
2024-12-22 22:10:14 -03:00
2024-12-26 12:39:38 -03:00
1. Generating and commititing a JSON file based on the `readme.txt`.
- The `JSON` file will be used by plugin/theme to check updates.
- The `JSON` file will be created on `wp-dist/data-json`.
2. Creating a new release with a `.zip` distribution file.
- The `.zip` file follows the folder structure requires by WordPress.
- You can define folders or files to be excluded from the `.zip` file. _To more details check the section [Preparing the Distribution File: Excluding Paths/Files from the ZIP](#preparing-the-distribution-file-excluding-pathsfiles-from-the-zip)_
2024-12-22 22:10:14 -03:00
2024-12-26 12:39:38 -03:00
Use this action to streamline the self-hosting process for your WordPress plugins and themes.
2024-12-23 03:10:20 -03:00
## How to Use
2024-12-26 12:39:38 -03:00
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, youll 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.
2024-12-23 03:10:20 -03:00
- **Quick Start Guide:** Explore our guide [How to Self-Host WordPress Plugins on Github and Deliver Updates](https://eduardovillao.me/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.
2024-12-23 03:10:20 -03:00
- **Required Integration:** Check out [WP Self-Host Updater Checker](https://github.com/eduardovillao/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.
2024-12-23 03:10:20 -03:00
### Requirements
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
Before using this GitHub Action, ensure the following:
- **`readme.txt` File**: A valid WordPress plugin readme file must exist in the root of your repository.
2024-12-23 03:10:20 -03:00
- **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:
1. Navigate to `.github/workflows/`.
2. Create a new file, e.g., `generate-dist-file.yaml`.
3. Add the following content to the file:
```yaml
name: Generate Dist File for Plugin
2024-12-22 22:10:14 -03:00
on:
push:
2024-12-22 22:29:56 -03:00
tags:
- '*'
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
permissions:
contents: write
2024-12-22 22:10:14 -03:00
jobs:
generate-json-and-release:
2024-12-22 22:10:14 -03:00
runs-on: ubuntu-latest
steps:
2024-12-23 03:10:20 -03:00
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: main
2024-12-22 22:10:14 -03:00
- name: Run WP Self-Host Update JSON Generator
2024-12-23 03:26:58 -03:00
uses: eduardovillao/wp-self-host-updater-generator@main
2024-12-23 03:10:20 -03:00
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
```
2024-12-23 03:10:20 -03:00
### Important Notes
2024-12-23 03:10:20 -03:00
1. **Permissions**: Ensure that `contents: write` is defined in the workflow file for the `GITHUB_TOKEN`.
2. **Repository Checkout**: The first step must check out the repository, specifying the branch where the JSON file will be committed (`main` or `master`).
3. **Trigger Events**: Currently, the Action supports triggers only when a tag is created. Future versions may support additional trigger events.
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
---
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
### Preparing the Distribution File: Excluding Paths/Files from the ZIP
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
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.
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
Heres an example of a `.gitattributes` file:
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
```gitattributes
# Exclude the wp-dist folder and its contents
wp-dist/ export-ignore
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
# Exclude hidden files and directories
.* export-ignore
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
# Exclude Git metadata
.git/ export-ignore
2024-12-22 22:10:14 -03:00
2024-12-23 03:10:20 -03:00
# 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
2024-12-22 22:10:14 -03:00
tests/ export-ignore
2024-12-23 03:10:20 -03:00
*.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
```