Public Access
38a975ee57
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Remove VERSION: XX.YY.ZZ lines from 213 file headers across PHP, TypeScript, TF definitions, workflows, CSS, markdown, and XML files. Version is tracked in composer.json and CHANGELOG.md only. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.6 KiB
3.6 KiB
Module Update Server
This module uses update.txt hosted in the repo root to enable Dolibarr's built-in update checker.
How It Works
- When a PR is merged to
main, theauto-release.ymlworkflow:- Reads the version from
README.md - Sets
$this->versionin the module descriptor to the real version - Creates a GitHub Release with a git tag
- Writes
update.txtto the repo root
- Reads the version from
- The module descriptor's
$this->url_last_versionpoints to the rawupdate.txtURL - Dolibarr's admin panel fetches this URL to check for available updates
Setup
1. Module Descriptor
In src/core/modules/mod*.class.php, ensure these lines are in the constructor:
// Version — 'development' on dev branches, real version set by auto-release on merge to main
$this->version = 'development';
// Update check — points to update.txt written by auto-release workflow
$this->url_last_version = 'https://raw.githubusercontent.com/mokoconsulting-tech/REPO_NAME/main/update.txt';
Replace REPO_NAME with this repository's name.
2. Version Parser
Add this method to the module descriptor class to parse the JSON response:
/**
* Get the latest available version from the update server.
*
* Reads update.txt from the GitHub repo and extracts the version field.
* Called by Dolibarr's module update checker.
*
* @return string Latest version number, or empty string on failure
*/
public function getLatestVersion(): string
{
if (empty($this->url_last_version)) {
return '';
}
$content = @file_get_contents($this->url_last_version);
if ($content === false) {
return '';
}
$data = json_decode($content, true);
return $data['version'] ?? '';
}
3. That's It
Everything else is automated:
deploy-dev.ymlsets version to"development"on dev branchesauto-release.ymlsets the real version and writesupdate.txton releasesync-version-on-merge.ymlbumps the patch version in README.md
update.txt Format
{
"version": "01.02.03",
"tag": "v01.02.03",
"repo": "mokoconsulting-tech/REPO_NAME",
"release_url": "https://git.mokoconsulting.tech/mokoconsulting-tech/REPO_NAME/releases/tag/v01.02.03",
"updated": "2026-03-27T00:00:00Z"
}
Do not edit
update.txtmanually — it is auto-generated by the release workflow.
Version Lifecycle
dev/** branch → $this->version = "development" (no update.txt)
merge to main → $this->version = "01.02.03" → update.txt written → GitHub Release
next commit → README auto-bumps to 01.02.04 (no release yet)
Troubleshooting
| Issue | Solution |
|---|---|
update.txt doesn't exist |
Merge a PR to main — the first release creates it |
| Version shows "development" | Expected on dev/** branches — real version set on release |
| Dolibarr doesn't detect updates | Check $this->url_last_version URL returns valid JSON |
| Wrong version in update.txt | Check README.md VERSION field — it's the source of truth |
Test the URL
curl -s https://raw.githubusercontent.com/mokoconsulting-tech/REPO_NAME/main/update.txt | jq .