Automatic Updates
There have been a few evolutions regarding the ways we deal with automatic updates, with many different solutions being explored in Terra. Despite how much our automatic package update system evolves, we still make our best effort to document the latest way to set up automatic updates in Terra. (Seriously!)
Solutions
AndaX (Andaman Rhai scripts)
Yes, I know it sounds unusual, but .rhai
scripts are used to update packages in Terra. You can check out the Rhai (opens in a new tab) documentations.
Put your Rhai script in update.rhai
next to the corresponding anda.hcl
file. Andaman will detect it automatically.
// An example of AndaX update script.
let ver = gh("FyraLabs/subatomic"); // gets latest version from GitHub
rpm.version(ver); // updates the version in the spec file using `ver`
;
)Updates are triggered every 10 minutes using anda update
.
Actually, the full command (opens in a new tab) for auto-updating normal packages is: (as of 2024-08-09)
RUST_BACKTRACE=full GITHUB_TOKEN=... anda update -vv --excludes nightly=1 --excludes updbranch=1
Nightly packages
Nightly packages are updated every 24 hours using
anda update -vv --filters nightly=1
.
Their anda.hcl
files should look something like this:
project pkg {
rpm {
spec = "pkg.spec"
}
labels {
nightly = 1
}
}
Per-branch auto-update scripts
Terra supports updating a package for specific branches instead of updating a package for all branches.
This is achieved using --filters updbranch=1 --labels branch=f41
(f41
is replaced by the branch name).
The update command is run every 30 minutes.
The anda.hcl
file should look like this:
project pkg {
rpm {
spec = "pkg.spec"
}
labels {
updbranch = 1
}
}
You can obtain the branch name during runtime in Rhai using labels.branch
(string).
You MUST NOT use this feature if the script ends up bumping versions across all branches at the same time. This feature should only be used under cases where the version is different for different branch but for the same package.
Consequently, under normal circumstances and without approval, you are NOT allowed to use GitHub/GitLab related functions.
Functions and Modules
In most cases, rpm.version(gh("..."));
as a one-liner is enough to make it work™.
Documentations for more functions are available in the Andaman
devdocs.
Guidelines
Avoid using the GitHub API for fetching the latest versions. You may use GitLab, crates.io, Pypi, etc. instead. This is because GitHub has an API rate-limit.
You might see scripts with if filters.contains("nightly")
. This if
statement is no longer needed.