Skip to content

Commit

Permalink
add --no-sign to hemtt release and config
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Mar 16, 2023
1 parent 2d0f162 commit 5a89547
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
9 changes: 8 additions & 1 deletion bin/src/commands/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ pub fn cli() -> Command {
.about("Release the project")
.long_about("Release your project"),
)
.arg(
clap::Arg::new("no-sign")
.long("no-sign")
.help("Do not sign the PBOs"),
)
}

pub fn execute(matches: &ArgMatches) -> Result<(), Error> {
let ctx = Context::new("release")?;
let mut executor = Executor::new(&ctx);

executor.add_module(Box::new(Sign::new()));
if matches.get_one::<bool>("no-sign") != Some(&true) && ctx.config().hemtt().release().sign() {
executor.add_module(Box::new(Sign::new()));
}

build::execute(matches, &mut executor)?;

Expand Down
27 changes: 27 additions & 0 deletions bin/src/config/project/hemtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct Features {
#[serde(default)]
build: BuildOptions,

#[serde(default)]
release: ReleaseOptions,

#[serde(default)]
/// Can PBO prefixes have a leading slash?
///
Expand Down Expand Up @@ -42,6 +45,11 @@ impl Features {
&self.build
}

#[must_use]
pub const fn release(&self) -> &ReleaseOptions {
&self.release
}

#[must_use]
pub const fn pbo_prefix_allow_leading_slash(&self) -> bool {
if let Some(allow) = self.pbo_prefix_allow_leading_slash {
Expand Down Expand Up @@ -123,3 +131,22 @@ impl BuildOptions {
}
}
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct ReleaseOptions {
#[serde(default)]
/// Should the PBOs be signed?
/// Default: true
sign: Option<bool>,
}

impl ReleaseOptions {
#[must_use]
pub const fn sign(&self) -> bool {
if let Some(sign) = self.sign {
sign
} else {
true
}
}
}
1 change: 1 addition & 0 deletions bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub fn execute(matches: &ArgMatches) -> Result<(), AppError> {
}
}

#[must_use]
pub fn is_ci() -> bool {
// TODO: replace with crate if a decent one comes along
let checks = vec![
Expand Down
4 changes: 2 additions & 2 deletions bin/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn check() -> Result<Option<String>, Error> {
use serde::Deserialize;
use serde::Serialize;

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct Release {
#[derive(Serialize, Deserialize)]
struct Release {
pub tag_name: String,
}
28 changes: 28 additions & 0 deletions book/commands-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
Usage: hemtt.exe release [OPTIONS]

Options:
<a href="#--no-sign">--no-sign</a>
Do not sign the PBOs

<a href="commands-build.md#--no-bin">--no-bin</a>
Do not binarize files

<a href="commands-build.md#--no-rapify">--no-rap</a>
Do not rapify files

<a href="commands.md#-t---threads">-t, --threads &lt;threads&gt;</a>
Number of threads, defaults to # of CPUs

Expand All @@ -27,3 +36,22 @@ It will create two zip archives in the `releases` folder:
## Configuration

`hemtt release` is built the same way as [`hemtt build`](commands-build.md), and will use its configuration.

```toml
[hemtt.release]
sign = false # Default: true
```

### sign

If `sign` is set to `false`, a `bikey` will not be created, and the PBOs will not be signed.

```admonish danger
All public releases of your mods should be signed. This will be a requirement of many communities, and is an important security feature.
```

## Options

### `--no-sign`

Do not sign the PBOs or create a `bikey`.

0 comments on commit 5a89547

Please sign in to comment.