mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-05 16:00:50 +00:00
better build version management
This commit is contained in:
@@ -79,7 +79,9 @@ impl Resolve<RunBuild, (User, Update)> for State {
|
||||
let _action_guard =
|
||||
action_state.update(|state| state.building = true)?;
|
||||
|
||||
build.config.version.increment();
|
||||
if build.config.auto_increment_version {
|
||||
build.config.version.increment();
|
||||
}
|
||||
update.version = build.config.version;
|
||||
update_update(update.clone()).await?;
|
||||
|
||||
|
||||
@@ -212,6 +212,7 @@ impl TryFrom<Build> for monitor_client::entities::build::Build {
|
||||
builder_id: String::new(),
|
||||
skip_secret_interp: value.skip_secret_interp,
|
||||
version: value.version.into(),
|
||||
auto_increment_version: true,
|
||||
image_name: Default::default(),
|
||||
image_tag: Default::default(),
|
||||
git_provider: String::from("github.com"),
|
||||
|
||||
@@ -139,6 +139,7 @@ impl From<BuildConfig>
|
||||
minor: value.version.minor,
|
||||
patch: value.version.patch,
|
||||
},
|
||||
auto_increment_version: true,
|
||||
image_name: Default::default(),
|
||||
image_tag: Default::default(),
|
||||
git_provider: String::from("github.com"),
|
||||
|
||||
@@ -124,6 +124,7 @@ impl From<BuildConfig>
|
||||
minor: value.version.minor,
|
||||
patch: value.version.patch,
|
||||
},
|
||||
auto_increment_version: true,
|
||||
image_name: Default::default(),
|
||||
image_tag: Default::default(),
|
||||
git_provider: String::from("github.com"),
|
||||
|
||||
@@ -92,6 +92,13 @@ pub struct BuildConfig {
|
||||
#[builder(default)]
|
||||
pub version: Version,
|
||||
|
||||
/// Whether to automatically increment the patch on every build.
|
||||
/// Default is `true`
|
||||
#[serde(default = "default_auto_increment_version")]
|
||||
#[builder(default = "default_auto_increment_version()")]
|
||||
#[partial_default(default_auto_increment_version())]
|
||||
pub auto_increment_version: bool,
|
||||
|
||||
/// An alternate name for the image pushed to the repository.
|
||||
/// If this is empty, it will use the build name.
|
||||
///
|
||||
@@ -256,6 +263,10 @@ impl BuildConfig {
|
||||
}
|
||||
}
|
||||
|
||||
fn default_auto_increment_version() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_git_provider() -> String {
|
||||
String::from("github.com")
|
||||
}
|
||||
@@ -286,6 +297,7 @@ impl Default for BuildConfig {
|
||||
builder_id: Default::default(),
|
||||
skip_secret_interp: Default::default(),
|
||||
version: Default::default(),
|
||||
auto_increment_version: default_auto_increment_version(),
|
||||
image_name: Default::default(),
|
||||
image_tag: Default::default(),
|
||||
git_provider: default_git_provider(),
|
||||
|
||||
@@ -374,6 +374,11 @@ export interface BuildConfig {
|
||||
builder_id?: string;
|
||||
/** The current version of the build. */
|
||||
version?: Version;
|
||||
/**
|
||||
* Whether to automatically increment the patch on every build.
|
||||
* Default is `true`
|
||||
*/
|
||||
auto_increment_version: boolean;
|
||||
/**
|
||||
* An alternate name for the image pushed to the repository.
|
||||
* If this is empty, it will use the build name.
|
||||
|
||||
@@ -284,8 +284,8 @@ export const ConfigAgain = <
|
||||
case "string":
|
||||
return (
|
||||
<ConfigInput
|
||||
key={args?.label ?? key.toString()}
|
||||
label={key.toString()}
|
||||
key={key.toString()}
|
||||
label={args?.label ?? key.toString()}
|
||||
value={value}
|
||||
onChange={(value) => set({ [key]: value } as Partial<T>)}
|
||||
disabled={disabled}
|
||||
|
||||
@@ -97,6 +97,9 @@ export const ConfigInput = ({
|
||||
placeholder,
|
||||
onChange,
|
||||
onBlur,
|
||||
className,
|
||||
inputLeft,
|
||||
inputRight,
|
||||
}: {
|
||||
label: string;
|
||||
boldLabel?: boolean;
|
||||
@@ -106,17 +109,36 @@ export const ConfigInput = ({
|
||||
placeholder?: string;
|
||||
onChange?: (value: string) => void;
|
||||
onBlur?: (value: string) => void;
|
||||
className?: string;
|
||||
inputLeft?: ReactNode;
|
||||
inputRight?: ReactNode;
|
||||
}) => (
|
||||
<ConfigItem label={label} boldLabel={boldLabel} description={description}>
|
||||
<Input
|
||||
className="max-w-[75%] lg:max-w-[400px]"
|
||||
type={typeof value === "number" ? "number" : undefined}
|
||||
value={value}
|
||||
onChange={(e) => onChange && onChange(e.target.value)}
|
||||
onBlur={(e) => onBlur && onBlur(e.target.value)}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
/>
|
||||
{inputLeft || inputRight ? (
|
||||
<div className="flex gap-2 items-center">
|
||||
{inputLeft}
|
||||
<Input
|
||||
className={cn("max-w-[75%] lg:max-w-[400px]", className)}
|
||||
type={typeof value === "number" ? "number" : undefined}
|
||||
value={value}
|
||||
onChange={(e) => onChange && onChange(e.target.value)}
|
||||
onBlur={(e) => onBlur && onBlur(e.target.value)}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
/>
|
||||
{inputRight}
|
||||
</div>
|
||||
) : (
|
||||
<Input
|
||||
className={cn("max-w-[75%] lg:max-w-[400px]", className)}
|
||||
type={typeof value === "number" ? "number" : undefined}
|
||||
value={value}
|
||||
onChange={(e) => onChange && onChange(e.target.value)}
|
||||
onBlur={(e) => onBlur && onBlur(e.target.value)}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
</ConfigItem>
|
||||
);
|
||||
|
||||
@@ -250,7 +272,7 @@ export const ProviderSelector = ({
|
||||
onBlur={() => setCustomMode(false)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
setCustomMode(false)
|
||||
setCustomMode(false);
|
||||
}
|
||||
}}
|
||||
autoFocus
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Config } from "@components/config";
|
||||
import {
|
||||
AccountSelectorConfig,
|
||||
AddExtraArgMenu,
|
||||
ConfigInput,
|
||||
ConfigItem,
|
||||
ImageRegistryConfig,
|
||||
InputList,
|
||||
@@ -68,49 +69,24 @@ export const BuildConfig = ({
|
||||
label: "Version",
|
||||
labelHidden: true,
|
||||
components: {
|
||||
version: (version, set) => {
|
||||
const { major, minor, patch } = version ?? {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
};
|
||||
version: (_version, set) => {
|
||||
const version =
|
||||
typeof _version === "object"
|
||||
? `${_version.major}.${_version.major}.${_version.patch}`
|
||||
: _version;
|
||||
return (
|
||||
<ConfigItem
|
||||
<ConfigInput
|
||||
className="text-lg w-[200px]"
|
||||
label="Version"
|
||||
description="Increment the build's major / minor version. The patch number will be incremented for every build."
|
||||
>
|
||||
<div className="flex gap-4 items-center">
|
||||
<div className="text-xl">
|
||||
v{major}.{minor}.{patch}
|
||||
</div>
|
||||
{!disabled && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
set({
|
||||
version: { major: major + 1, minor: 0, patch: 0 },
|
||||
})
|
||||
}
|
||||
>
|
||||
+ Major
|
||||
</Button>
|
||||
)}
|
||||
{!disabled && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
set({
|
||||
version: { major, minor: minor + 1, patch: 0 },
|
||||
})
|
||||
}
|
||||
>
|
||||
+ Minor
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</ConfigItem>
|
||||
placeholder="0.0.0"
|
||||
value={version}
|
||||
onChange={(version) => set({ version: version as any })}
|
||||
disabled={disabled}
|
||||
boldLabel
|
||||
/>
|
||||
);
|
||||
},
|
||||
auto_increment_version: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user