anodizer_core/config/publishers/chocolatey.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::super::{PostPublishPollConfig, StringOrBool, deserialize_string_or_bool_opt};
5use super::RepositoryConfig;
6
7// ---------------------------------------------------------------------------
8// ChocolateyConfig
9// ---------------------------------------------------------------------------
10
11#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
12#[serde(default, deny_unknown_fields)]
13pub struct ChocolateyConfig {
14 /// Override the package name (default: crate name).
15 pub name: Option<String>,
16 /// Build IDs filter: only include artifacts whose `id` is in this list.
17 pub ids: Option<Vec<String>>,
18 /// Unified project repo config (owner/name). Used to derive
19 /// `<projectUrl>` (the Chocolatey gallery link) and download URLs.
20 /// `<projectUrl>` resolves through `project_url:` (if set) → derived
21 /// `https://github.com/{repository.owner}/{repository.name}`.
22 pub repository: Option<RepositoryConfig>,
23 /// URL shown as the package source in the Chocolatey gallery.
24 pub package_source_url: Option<String>,
25 /// Package owners (Chocolatey gallery user).
26 pub owners: Option<String>,
27 /// Package title (default: project name).
28 pub title: Option<String>,
29 /// Package author(s) displayed in the Chocolatey gallery.
30 pub authors: Option<String>,
31 /// Project homepage URL.
32 pub project_url: Option<String>,
33 /// Custom URL template for download URLs (overrides release URL).
34 pub url_template: Option<String>,
35 /// URL to the package icon image shown in the Chocolatey gallery.
36 pub icon_url: Option<String>,
37 /// Copyright notice.
38 pub copyright: Option<String>,
39 /// Package description (supports markdown).
40 pub description: Option<String>,
41 /// SPDX license identifier (e.g., "MIT", "Apache-2.0").
42 pub license: Option<String>,
43 /// Optional explicit license URL. Falls back to
44 /// `https://opensource.org/licenses/<license>` when not set.
45 pub license_url: Option<String>,
46 /// Require license acceptance before install.
47 pub require_license_acceptance: Option<bool>,
48 /// Source code project URL.
49 pub project_source_url: Option<String>,
50 /// Documentation URL.
51 pub docs_url: Option<String>,
52 /// Bug tracker URL.
53 pub bug_tracker_url: Option<String>,
54 /// Tags for the Chocolatey gallery (joined with single spaces in the
55 /// emitted nuspec). Always a typed list — the legacy
56 /// space-separated-string form was dropped now for
57 /// IDE-completion friendliness and to remove whitespace ambiguity.
58 pub tags: Option<Vec<String>>,
59 /// Short summary of the package.
60 pub summary: Option<String>,
61 /// Release notes for this version.
62 pub release_notes: Option<String>,
63 /// Package dependencies with optional version constraints.
64 pub dependencies: Option<Vec<ChocolateyDependency>>,
65 /// Chocolatey API key for `choco push`. Falls back to `CHOCOLATEY_API_KEY` env var.
66 pub api_key: Option<String>,
67 /// Push source URL (default: "https://push.chocolatey.org/").
68 pub source_repo: Option<String>,
69 /// Skip pushing to the Chocolatey community repository. Bool, string, or
70 /// template expression (e.g. `"{{ .IsSnapshot }}"`). Accepts the legacy
71 /// `skip_publish:` spelling for back-compat with configs;
72 /// canonical name is `skip:` to align with every other publisher.
73 #[serde(
74 default,
75 alias = "skip_publish",
76 deserialize_with = "deserialize_string_or_bool_opt"
77 )]
78 pub skip: Option<StringOrBool>,
79 /// Artifact selection: "archive" (default), "msi", or "nsis".
80 #[serde(rename = "use")]
81 pub use_artifact: Option<String>,
82 /// amd64 microarchitecture variant filter (e.g. "v1", "v2", "v3", "v4").
83 /// Only artifacts matching this variant are included. Default: "v1".
84 pub amd64_variant: Option<String>,
85 /// Post-publish moderation-queue polling settings. When unset, polling
86 /// runs with defaults (enabled, 30s interval, 30m timeout). Polling can
87 /// be disabled globally via `--no-post-publish-poll`.
88 pub post_publish_poll: Option<PostPublishPollConfig>,
89 /// When true, re-push the nupkg even when a version is already in the
90 /// community moderation queue (PackageStatus=Submitted). Chocolatey's API
91 /// accepts re-pushes of in-moderation versions; the new nupkg replaces the
92 /// queued one. When false (default), the push is skipped and a warning is
93 /// emitted so the operator sees that the publisher did not push.
94 #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
95 pub republish_in_moderation: Option<StringOrBool>,
96}
97
98/// Chocolatey package dependency with optional version constraint.
99#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
100#[serde(default)]
101pub struct ChocolateyDependency {
102 /// Chocolatey package ID of the dependency.
103 pub id: String,
104 /// Minimum version constraint for the dependency (e.g., "[1.0.0,)").
105 pub version: Option<String>,
106}