1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
use crate::constants; use crate::prelude::*; use crate::types::{HaltConfig, ReleaseConfig}; use semver::Version; use tokio::fs; mod executor; pub async fn run_release_checklist(config_file_path: &str, release_version: &str) -> crate::Result<()> { let config_file_path = fs::canonicalize(config_file_path) .await .context(format!("Config file path does not exist: {}", config_file_path))?; let project_root_dir = config_file_path .parent() .ok_or_else(|| crate::Error::new("Couldn't access project root dir"))?; let release_version = { let version = release_version.trim(); let version = if version.starts_with("v") { version.trim_start_matches("v") } else { version }; Version::parse(version).context(format!("Invalid release version provided: '{}'", release_version))? }; let release_config = ReleaseConfig::parse( fs::read_to_string(config_file_path.as_path()) .await .context("Couldn't read the config file as text")? .as_str(), ) .context("Couldn't parse the config file as a yaml file")?; let halt_config = fs::read_to_string(project_root_dir.join(constants::HALT_CONFIG_FILE_NAME)) .await .ok() .and_then(|config_text| HaltConfig::parse(config_text.as_str()).ok()); executor::execute_checklist( &release_config, halt_config.as_ref(), &release_version, project_root_dir, ) .await?; Ok(()) }