Skip to content

Commit

Permalink
release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett committed Feb 15, 2019
1 parent dca70af commit 28e77c9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hemtt"
version = "0.3.1"
version = "0.4.0"
authors = ["Brett <[email protected]>"]
edition = "2018"

Expand Down
51 changes: 51 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,55 @@ pub fn build(p: &crate::project::Project) -> Result<(), std::io::Error> {
)?;
}
Ok(())
}

pub fn release(p: &crate::project::Project) -> Result<(), std::io::Error> {
let version = crate::project::get_version()?;
println!("Building Release Version: {}", version);
build(&p)?;
if !Path::new("releases").exists() {
fs::create_dir("releases")?;
}
if !Path::new(&format!("releases/{}", version)).exists() {
fs::create_dir(format!("releases/{}", version))?;
}
if !Path::new(&format!("releases/{}/@{}", version, p.prefix)).exists() {
fs::create_dir(format!("releases/{}/@{}", version, p.prefix))?;
}
if !Path::new(&format!("releases/{}/@{}/addons", version, p.prefix)).exists() {
fs::create_dir(format!("releases/{}/@{}/addons", version, p.prefix))?;
}
if !Path::new(&format!("releases/{}/@{}/keys", version, p.prefix)).exists() {
fs::create_dir(format!("releases/{}/@{}/keys", version, p.prefix))?;
}
for file in &p.files {
fs::copy(file, format!("releases/{}/@{}/{}", version, p.prefix, file))?;
}
if !Path::new("keys").exists() {
fs::create_dir("keys")?;
}
if !Path::new(&format!("keys/{}.bikey", p.prefix)).exists() {
armake2::sign::cmd_keygen(PathBuf::from(&p.prefix))?;
fs::rename(format!("{}.bikey", p.prefix), format!("keys/{}.bikey", p.prefix))?;
fs::rename(format!("{}.biprivatekey", p.prefix), format!("keys/{}.biprivatekey", p.prefix))?;
}
fs::copy(format!("keys/{}.bikey", p.prefix), format!("releases/{0}/@{1}/keys/{1}.bikey", version, p.prefix))?;
for entry in fs::read_dir("addons").unwrap() {
let entry = entry.unwrap();
let path = entry.path();
let cpath = path.clone();
let cpath = cpath.to_str().unwrap().replace(r#"\"#,"/");
if !path.ends_with(".pbo") && !cpath.contains(p.prefix.as_str()) {
continue;
}
fs::copy(&cpath, format!("releases/{}/@{}/{}", version, p.prefix, cpath))?;
armake2::sign::cmd_sign(
PathBuf::from(format!("keys/{}.biprivatekey", p.prefix)),
PathBuf::from(format!("releases/{}/@{}/{}", version, p.prefix, cpath)),
Some(PathBuf::from(format!("releases/{0}/@{1}/{2}.{0}.bisign", version, p.prefix, cpath))),
armake2::sign::BISignVersion::V3
)?;
println!(" {} {}", "Signed", cpath);
}
Ok(())
}
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Usage:
hemtt init
hemtt create
hemtt addon <name>
hemtt build
hemtt build [--release]
hemtt update
hemtt (-h | --help)
hemtt --version
Expand Down Expand Up @@ -49,6 +49,7 @@ struct Args {
flag_verbose: bool,
flag_force: bool,
flag_version: bool,
flag_release: bool,
arg_name: String,
}

Expand Down Expand Up @@ -112,7 +113,11 @@ fn main() {
if args.flag_force {
files::clear_pbos(&p).unwrap();
}
build::build(&p).unwrap();
if args.flag_release {
build::release(&p).unwrap()
} else {
build::build(&p).unwrap();
}
} else if args.cmd_update {
let target = self_update::get_target().unwrap();
let status = self_update::backends::github::Update::configure().unwrap()
Expand All @@ -124,7 +129,7 @@ fn main() {
.current_version(VERSION)
.build().unwrap()
.update().unwrap();
println!("Update: {}", status.version());
println!("Using Version: {}", status.version());
}
}

Expand Down

0 comments on commit 28e77c9

Please sign in to comment.