Add a New Package

We use ollam as an example to show how to add a new package to the generator.

Step 1: Create a new package module in ./huber-generator/src/pkg

You can specify the exact artifact name template or use the default automatic artifact name recognition.

#![allow(unused)]
fn main() {
#[allow(dead_code)]
pub fn release() -> Package {
    Package {
        name: "ollama".to_string(),
        source: PackageSource::Github {
            owner: "ollama".to_string(),
            repo: "ollama".to_string(),
        },

        targets: vec![
            PackageTargetType::LinuxAmd64(PackageManagement {
                artifact_templates: vec!["ollama-linux-amd64.tgz".to_string()],
                ..Default::default()
            }),
            PackageTargetType::LinuxArm64(PackageManagement {
                artifact_templates: vec!["ollama-linux-arm64.tgz".to_string()],
                ..Default::default()
            }),
            PackageTargetType::MacOSAmd64(PackageManagement {
                artifact_templates: vec!["ollama-darwin".to_string()],
                ..Default::default()
            }),
            PackageTargetType::WindowsAmd64(PackageManagement {
                artifact_templates: vec!["ollama-windows-amd64.zip".to_string()],
                ..Default::default()
            }),
        ],
        ..Default::default()
    }
}
}

If the artifact name includes env::consts::OS, env::consts::ARCH, values defined in GOOS/GOARCH and release semantic versions, you can use the default automatic artifact name recognition below instead of specifying the artifact name template.

Besides downloading executables, Huber also supports downloading compressed files to extract executables from them. If the artifact name ends with .tar.gz, .tar.xz, .zip, .tar, .tgz, or .gz, Huber will automatically decompress the file after downloading.

The following table shows some automatic artifact name recognition for different operating systems and architectures:

OSARCHAsset nameRenamed asset name
linuxamd64, x86_64, ..ollama-linux-amd64ollam
linuxaarch64, arm64, ..ollama-linux-arm64.tar.gzollam.tar.gz
macos, darwinaarch64, arm64, ..ollama-darwin-arm64ollam
windowsamd64, X86_64, ..ollama-windows-amd64.zipollam.zip
#![allow(unused)]
fn main() {
#[allow(dead_code)]
pub fn release() -> Package {
    Package {
        name: "ollama".to_string(),
        source: PackageSource::Github {
            owner: "ollama".to_string(),
            repo: "ollama".to_string(),
        },

        targets: vec![
            PackageTargetType::LinuxAmd64(Default::default()),
            PackageTargetType::LinuxArm64(Default::default()),
            PackageTargetType::MacOSAmd64(Default::default()),
            PackageTargetType::WindowsAmd64(Default::default()),
        ],
        ..Default::default()
    }
}
}

Step 2: Declare the package module in ./huber-generator/src/pkg/mod.rs

#![allow(unused)]
fn main() {
pub mod ollama;
}

Step 3: Export the package to the release function in ./huber-generator/src/build.rs

#![allow(unused)]

fn main() {
fn releases() -> Vec<Package> {
    vec![
        // ... existing packages
        // Add the new package here
        ollama::release(),
    ]
}
}

Step 4: Run the generator

After running the following command, the generator will automatically generate the package information to the ./generated-v1 directory and update the ./docs/src/contributing/huber-managed-packages.md file.

just generate

Finally, please create a pull request to merge the changes into the main branch. Thank you for contributing to Huber!