gh_workflow/
release_plz.rs1use derive_setters::Setters;
4
5use crate::{Step, Use};
6
7#[derive(Clone, Default, Setters)]
8#[setters(strip_option, into)]
9pub struct Release {
10 pub command: Option<Command>,
13
14 pub registry: Option<String>,
19
20 pub manifest_path: Option<String>,
24
25 pub version: Option<String>,
27
28 pub config: Option<String>,
31
32 pub token: Option<String>,
34
35 pub backend: Option<Backend>,
37}
38
39#[derive(Clone)]
40pub enum Command {
41 ReleasePR,
44
45 Release,
48}
49
50impl std::fmt::Display for Command {
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52 match self {
53 Command::ReleasePR => write!(f, "release-pr"),
54 Command::Release => write!(f, "release"),
55 }
56 }
57}
58
59#[derive(Clone)]
60pub enum Backend {
61 GitHub,
62 Gitea,
63}
64
65impl std::fmt::Display for Backend {
66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67 match self {
68 Backend::GitHub => write!(f, "github"),
69 Backend::Gitea => write!(f, "gitea"),
70 }
71 }
72}
73
74impl From<Release> for Step<Use> {
75 fn from(value: Release) -> Self {
76 let mut step = Step::new("Release Plz").uses("release-plz", "action", "v0.5");
77
78 if let Some(command) = value.command {
79 step = step.add_with(("command", command.to_string()));
80 }
81
82 if let Some(registry) = value.registry {
83 step = step.add_with(("registry", registry));
84 }
85
86 if let Some(manifest_path) = value.manifest_path {
87 step = step.add_with(("manifest_path", manifest_path));
88 }
89
90 if let Some(version) = value.version {
91 step = step.add_with(("version", version));
92 }
93
94 if let Some(config) = value.config {
95 step = step.add_with(("config", config));
96 }
97
98 if let Some(token) = value.token {
99 step = step.add_with(("token", token));
100 }
101
102 if let Some(backend) = value.backend {
103 step = step.add_with(("backend", backend.to_string()));
104 }
105
106 step
107 }
108}