Package Development and Deployment
Prerequisites: Testing
Creating a package
(@v1.13) pkg> generate Inventory
Generating project Inventory:
Inventory/Project.toml
Inventory/src/Inventory.jl
] generate creates a minimal package. PkgTemplates.jl creates a
complete one — tests, GitHub Actions CI, documentation, code coverage,
and a license:
# illustrative — needs the PkgTemplates package
using PkgTemplates
t = Template(user = "your-github-name", plugins = [GitHubActions(), Documenter{GitHubActions}(), Codecov()])
t("Inventory")
The development loop
(@v1.13) pkg> dev ./Inventory # use your local copy
julia> using Revise, Inventory # Revise reloads changes on save
julia> Inventory.total_value(...) # edit src/, call again, no restart
(Inventory) pkg> test
dev makes an environment use your working copy instead of a released
version. With Revise.jl loaded first, edits to the package's source
files take effect immediately.
Documentation and releases
- Write docstrings for every exported name; Documenter.jl builds a website from them and runs their examples as doctests.
- Follow semantic versioning in
Project.toml'sversionfield. - Register a package in the General registry with the Registrator GitHub app; TagBot then creates the Git tag and release.
- Add
[compat]bounds for every dependency — the registry requires them.
Load time and precompilation
Packages are precompiled when installed, and since Julia 1.9 native code is cached too. You can make the first call of your package fast by running a representative workload during precompilation with PrecompileTools.jl:
# illustrative — inside src/Inventory.jl
using PrecompileTools
@setup_workload begin
items = [Item("pen", 3, 1.5)]
@compile_workload begin
total_value(items)
end
end
Deploying applications
- Scripts and services — ship the project with its
Manifest.tomland runjulia --project -e 'using Pkg; Pkg.instantiate()'on the server (or in a Docker image built from the officialjuliaimage). - PackageCompiler.jl —
create_sysimagebakes packages into a custom system image for near-instant startup;create_appbuilds a relocatable application folder. - JuliaC.jl and the
--trimoption (experimental since Julia 1.12) compile a program into a small standalone executable by removing code it can't reach. - Web services — Oxygen.jl and Genie.jl are web frameworks; HTTP.jl is the underlying client and server.
- Notebooks and dashboards — publish Pluto notebooks as static HTML, or build interactive apps with Genie or Dash.jl.