- PHP 87.9%
- Shell 8.8%
- CSS 3.2%
- JavaScript 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo | ||
| assets/css | ||
| bin | ||
| includes | ||
| tests | ||
| .gitignore | ||
| .releaserc.json | ||
| CHANGELOG.md | ||
| commitlint.config.cjs | ||
| composer.json | ||
| composer.lock | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| phpunit.xml.dist | ||
| README.md | ||
| wp-git-releases.php | ||
WP Git Releases
WP Git Releases is a WordPress plugin that shows the latest release for a GitHub-compatible repository (GitHub, Gitea, or Forgejo).
It includes:
- An admin settings page
- A shortcode
- A widget
- Optional release notes body rendering from Markdown
Installation
- Copy this plugin folder into your WordPress plugins directory.
- Activate WP Git Releases from the WordPress admin.
- Open Settings -> WP Git Releases.
- Configure:
- Server Domain (example: github.com, codeberg.org, git.example.com)
- Project Owner
- Project Repository
Settings
- Server Domain: Domain for your Git server
- Project Owner: Repository owner or organization
- Project Repository: Repository name
- API Token (optional): Token for private repos or higher API limits
- Show Release Notes By Default: Controls whether release body is shown
- Cache Duration (minutes): API response cache duration using transients
- Debug Mode: Shows generated release API URL candidates and response diagnostics to administrators
Shortcode
Use the shortcode:
[git_release]
Optional attributes:
- show_body="1" or "0"
- show_assets="1" or "0"
- max_assets="0" for all, or any positive integer
- title="Your title"
Example:
[git_release show_body="1" show_assets="1" max_assets="5" title="Latest Download"]
Widget
Use the widget named:
WP Git Releases: Latest Release
Widget options:
- Title
- Show download assets
- Show release notes (Markdown)
- Max assets to display
API behavior
The plugin attempts these latest-release endpoints:
- GitHub domain:
- Other domains:
- https://{domain}/api/v1/repos/{owner}/{repo}/releases/latest (Gitea/Forgejo)
- https://{domain}/api/v3/repos/{owner}/{repo}/releases/latest (GitHub Enterprise style)
If an API token is configured, requests include:
- Authorization: Bearer {token}
- X-API-Token: {token}
Frontend styles
The plugin loads a frontend stylesheet for shortcode and widget output:
- assets/css/wgr-frontend.css
Testing
This repository includes WordPress PHPUnit scaffolding and integration tests.
- Install dev dependencies:
composer install
- Install WordPress test suite files:
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
- Run tests:
WP_TESTS_DIR=/tmp/wordpress-tests-lib vendor/bin/phpunit
Included tests:
- tests/test-plugin-load.php
- tests/test-release-render.php
Packaging for WordPress
Build a distributable plugin zip:
composer package
This creates a zip in dist/ named like:
- wp-git-releases-1.0.0.zip
The archive includes only the files WordPress needs to load the plugin:
- wp-git-releases.php
- includes/
- assets/
- README.md (if present)
- LICENSE (if present)
Conventional Commits
This project uses Conventional Commits and enforces them in CI.
Examples:
- feat: add support for repository tokens
- fix: sanitize release body output
- docs: clarify shortcode options
- chore: update release workflow
The commit header format is:
type(scope): short summary
Scope is optional. Common types are feat, fix, docs, chore, refactor, test, and ci.
Automated Releases (Forgejo + semantic-release)
Releases are generated by Forgejo Actions using semantic-release with:
- semantic versioning based on Conventional Commits
- automatic changelog updates (
CHANGELOG.md) - automatic plugin version updates in
wp-git-releases.php - automatic plugin zip creation and upload as a Forgejo release asset
Workflow files:
- .forgejo/workflows/ci.yml
- .forgejo/workflows/release.yml
Required Forgejo settings:
- Add repository secret
RELEASE_AUTHOR_TOKENwith permission to push tags/commits and create releases. - Ensure
GITHUB_TOKENis available to workflows for checkout. - Optionally add repository variable
FORGEJO_URLif your instance URL is not auto-detected. - Optionally set
RELEASE_AUTHOR_NAMEandRELEASE_AUTHOR_EMAILrepository variables to control git author metadata for release commits.
Useful local commands:
bash bin/package-plugin.shto build the plugin zipnpx semantic-release --dry-runto preview the next release locally
Notes
- Markdown rendering is done by an internal lightweight parser for common Markdown syntax.
- Output is sanitized through WordPress HTML sanitization.
License
This project is licensed under the MIT License. See LICENSE.