Skip to main content

anodizer_core/config/
installers.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::archives::{ArchiveFileSpec, ExtraFileSpec, TemplatedExtraFile};
5use super::build::BuildHooksConfig;
6use super::{StringOrBool, deserialize_string_or_bool_opt};
7
8// ---------------------------------------------------------------------------
9// DmgConfig
10// ---------------------------------------------------------------------------
11
12#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
13#[serde(default)]
14pub struct DmgConfig {
15    /// Unique identifier for this DMG config.
16    pub id: Option<String>,
17    /// Build IDs to include. Empty means all builds.
18    pub ids: Option<Vec<String>>,
19    /// Output DMG filename (supports templates).
20    pub name: Option<String>,
21    /// Additional files to include in the DMG (glob or {glob, name_template}).
22    pub extra_files: Option<Vec<ExtraFileSpec>>,
23    /// Extra files whose contents are rendered through the template engine before inclusion.
24    /// Unlike `extra_files` which copy as-is, template variables like `{{ .Tag }}` are expanded.
25    /// GoReleaser Pro feature.
26    pub templated_extra_files: Option<Vec<TemplatedExtraFile>>,
27    /// Remove source archives from artifacts, keeping only DMG.
28    pub replace: Option<bool>,
29    /// Output timestamp for reproducible builds.
30    pub mod_timestamp: Option<String>,
31    /// Skip this DMG config. Accepts bool or template string.
32    #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
33    pub skip: Option<StringOrBool>,
34    /// Which artifact type to package: "binary" (default) or "appbundle".
35    #[serde(rename = "use")]
36    pub use_: Option<String>,
37    /// amd64 microarchitecture variant filter (`v1` / `v2` / `v3` / `v4`).
38    /// When set, only artifacts with the matching `amd64_variant` metadata
39    /// are included. Mirrors GoReleaser Pro DMG's `goamd64: string` field.
40    /// When unset, all amd64 variants are included (no filtering).
41    pub goamd64: Option<String>,
42    /// Template-conditional: skip this DMG config if rendered result is "false"
43    /// or empty (GoReleaser Pro). Render failure hard-errors (not silent-skip).
44    #[serde(rename = "if")]
45    pub if_condition: Option<String>,
46}
47
48// ---------------------------------------------------------------------------
49// MsiConfig
50// ---------------------------------------------------------------------------
51
52#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
53#[serde(default)]
54pub struct MsiConfig {
55    /// Unique identifier for this MSI config.
56    pub id: Option<String>,
57    /// Build IDs to include. Empty means all builds.
58    pub ids: Option<Vec<String>>,
59    /// Path to the WiX source file (.wxs). Goes through template engine. Required.
60    pub wxs: Option<String>,
61    /// Output MSI filename (supports templates).
62    pub name: Option<String>,
63    /// WiX schema version: v3 or v4 (auto-detected from .wxs if omitted).
64    pub version: Option<String>,
65    /// Remove source archives from artifacts, keeping only MSI.
66    pub replace: Option<bool>,
67    /// Output timestamp for reproducible builds.
68    pub mod_timestamp: Option<String>,
69    /// Skip this MSI config. Accepts bool or template string.
70    /// Accepts the legacy `disable:` spelling via serde alias for back-compat
71    /// with imported GoReleaser configs (GR docs list `disable: string`).
72    #[serde(
73        default,
74        alias = "disable",
75        deserialize_with = "deserialize_string_or_bool_opt"
76    )]
77    pub skip: Option<StringOrBool>,
78    /// amd64 microarchitecture variant filter (`v1` / `v2` / `v3` / `v4`).
79    /// When set, only artifacts with the matching `amd64_variant` metadata
80    /// are included. Mirrors GoReleaser Pro MSI's `goamd64: string` field.
81    pub goamd64: Option<String>,
82    /// Additional files available in the WiX build context (simple filenames).
83    pub extra_files: Option<Vec<String>>,
84    /// WiX extensions to enable (e.g., "WixUIExtension"). Templates allowed.
85    pub extensions: Option<Vec<String>>,
86    /// Template-conditional: skip this MSI config if rendered result is "false"
87    /// or empty (GoReleaser Pro). Render failure hard-errors (not silent-skip).
88    #[serde(rename = "if")]
89    pub if_condition: Option<String>,
90    /// Pre/post MSI-build hooks (GoReleaser Pro v2.14+). Accepts `pre`/`post`
91    /// or `before`/`after` via BuildHooksConfig's serde aliases. Runs before
92    /// / after candle+light for each matched artifact.
93    pub hooks: Option<BuildHooksConfig>,
94}
95
96// ---------------------------------------------------------------------------
97// PkgConfig (macOS .pkg installer)
98// ---------------------------------------------------------------------------
99
100#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
101#[serde(default)]
102pub struct PkgConfig {
103    /// Unique identifier for this PKG config.
104    pub id: Option<String>,
105    /// Build IDs to include. Empty means all builds.
106    pub ids: Option<Vec<String>>,
107    /// Package identifier in reverse-domain notation (e.g. com.example.myapp). Required.
108    pub identifier: Option<String>,
109    /// Output PKG filename (supports templates).
110    pub name: Option<String>,
111    /// Installation path. Default: /usr/local/bin.
112    pub install_location: Option<String>,
113    /// Path to scripts directory containing preinstall/postinstall scripts.
114    pub scripts: Option<String>,
115    /// Additional files to include in the package (glob or {glob, name_template}).
116    pub extra_files: Option<Vec<ExtraFileSpec>>,
117    /// Remove source archives from artifacts, keeping only PKG.
118    pub replace: Option<bool>,
119    /// Output timestamp for reproducible builds.
120    pub mod_timestamp: Option<String>,
121    /// Which artifact type to package: "binary" (default) or "appbundle".
122    #[serde(rename = "use")]
123    pub use_: Option<String>,
124    /// Minimum macOS version (e.g. "10.13"). Forwarded to `productbuild --min-os-version`.
125    pub min_os_version: Option<String>,
126    /// Skip this PKG config. Accepts bool or template string.
127    #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
128    pub skip: Option<StringOrBool>,
129    /// Template-conditional: skip this PKG config if rendered result is "false"
130    /// or empty (GoReleaser Pro). Render failure hard-errors (not silent-skip).
131    #[serde(rename = "if")]
132    pub if_condition: Option<String>,
133}
134
135// ---------------------------------------------------------------------------
136// NsisConfig (Windows NSIS installer)
137// ---------------------------------------------------------------------------
138
139#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
140#[serde(default)]
141pub struct NsisConfig {
142    /// Unique identifier for this NSIS config.
143    pub id: Option<String>,
144    /// Build IDs to include. Empty means all builds.
145    pub ids: Option<Vec<String>>,
146    /// Output installer filename (supports templates).
147    pub name: Option<String>,
148    /// Path to the NSIS script template (.nsi). Goes through template engine.
149    pub script: Option<String>,
150    /// Additional files to include alongside the installer (glob or {glob, name_template}).
151    pub extra_files: Option<Vec<ExtraFileSpec>>,
152    /// Extra files whose contents are rendered through the template engine before inclusion.
153    /// Unlike `extra_files` which copy as-is, template variables like `{{ .Tag }}` are expanded.
154    /// GoReleaser Pro feature.
155    pub templated_extra_files: Option<Vec<TemplatedExtraFile>>,
156    /// Skip this NSIS config. Accepts bool or template string.
157    /// Accepts the legacy `disable:` spelling via serde alias for back-compat
158    /// with imported GoReleaser configs (GR docs list `disable: string`).
159    #[serde(
160        default,
161        alias = "disable",
162        deserialize_with = "deserialize_string_or_bool_opt"
163    )]
164    pub skip: Option<StringOrBool>,
165    /// amd64 microarchitecture variant filter (`v1` / `v2` / `v3` / `v4`).
166    /// When set, only artifacts with the matching `amd64_variant` metadata
167    /// are included. Mirrors GoReleaser Pro NSIS's `goamd64: string` field.
168    pub goamd64: Option<String>,
169    /// Remove source archives from artifacts, keeping only the installer.
170    pub replace: Option<bool>,
171    /// Output timestamp for reproducible builds.
172    pub mod_timestamp: Option<String>,
173    /// Template-conditional: skip this NSIS config if rendered result is "false"
174    /// or empty (GoReleaser Pro). Render failure hard-errors (not silent-skip).
175    #[serde(rename = "if")]
176    pub if_condition: Option<String>,
177}
178
179// ---------------------------------------------------------------------------
180// AppBundleConfig (macOS .app bundle)
181// ---------------------------------------------------------------------------
182
183#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
184#[serde(default)]
185pub struct AppBundleConfig {
186    /// Unique identifier for this app bundle config.
187    pub id: Option<String>,
188    /// Build IDs to include. Empty means all builds.
189    pub ids: Option<Vec<String>>,
190    /// Output .app bundle name (supports templates).
191    pub name: Option<String>,
192    /// Path to .icns icon file for the app bundle (supports templates).
193    pub icon: Option<String>,
194    /// Bundle identifier in reverse-DNS notation (e.g. com.example.myapp). Required.
195    pub bundle: Option<String>,
196    /// Additional files to include in the bundle (src/dst/info objects or glob strings).
197    pub extra_files: Option<Vec<ArchiveFileSpec>>,
198    /// Extra files whose contents are rendered through the template engine before inclusion.
199    /// Unlike `extra_files` which copy as-is, template variables like `{{ .Tag }}` are expanded.
200    /// GoReleaser Pro feature.
201    pub templated_extra_files: Option<Vec<TemplatedExtraFile>>,
202    /// Output timestamp for reproducible builds.
203    pub mod_timestamp: Option<String>,
204    /// Remove source archives from artifacts, keeping only the app bundle.
205    pub replace: Option<bool>,
206    /// Skip this app bundle config. Accepts bool or template string.
207    #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
208    pub skip: Option<StringOrBool>,
209    /// Template-conditional: skip this app bundle config if rendered result is
210    /// "false" or empty (GoReleaser Pro). Render failure hard-errors (not silent-skip).
211    #[serde(rename = "if")]
212    pub if_condition: Option<String>,
213}
214
215// ---------------------------------------------------------------------------
216// FlatpakConfig (Linux Flatpak bundle)
217// ---------------------------------------------------------------------------
218
219#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
220#[serde(default)]
221pub struct FlatpakConfig {
222    /// Unique identifier for this Flatpak config.
223    pub id: Option<String>,
224    /// Build IDs to include. Empty means all builds.
225    pub ids: Option<Vec<String>>,
226    /// Output .flatpak filename (supports templates).
227    pub name_template: Option<String>,
228    /// Flatpak application ID in reverse-DNS notation (e.g. org.example.MyApp). Required.
229    pub app_id: Option<String>,
230    /// Flatpak runtime (e.g. org.freedesktop.Platform). Required.
231    pub runtime: Option<String>,
232    /// Flatpak runtime version (e.g. "24.08"). Required.
233    pub runtime_version: Option<String>,
234    /// Flatpak SDK (e.g. org.freedesktop.Sdk). Required.
235    pub sdk: Option<String>,
236    /// Command to run inside the Flatpak sandbox. Defaults to first binary name.
237    pub command: Option<String>,
238    /// Sandbox permissions (e.g. --share=network, --socket=x11).
239    pub finish_args: Option<Vec<String>>,
240    /// Additional files to include alongside the binary (glob or {glob, name_template}).
241    pub extra_files: Option<Vec<ExtraFileSpec>>,
242    /// Remove source archives from artifacts, keeping only the Flatpak bundle.
243    pub replace: Option<bool>,
244    /// Output timestamp for reproducible builds.
245    pub mod_timestamp: Option<String>,
246    /// Skip this Flatpak config. Accepts bool or template string.
247    #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
248    pub skip: Option<StringOrBool>,
249}