commit 41833914308655b88bcb726d42772bcb9cbb8ff7
parent f1be30f83c4d544589ef693dac08b88abd5872d3
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 22 Nov 2021 09:25:17 +0100
hare release: move tag signing into separate func
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/cmd/hare/release.ha b/cmd/hare/release.ha
@@ -101,34 +101,7 @@ fn do_release(
shortlog(clfile, range)?;
git_runcmd("tag", "-aeF", changelog, newtag)?;
-
- fmt::printfln("Using SSH key {} for release signature.", key)!;
- const prefix = fmt::asprintf("--prefix={}-{}/", name, newtag);
- defer free(prefix);
- const archive = exec::cmd("git", "archive",
- "--format=tar.gz", prefix, newtag)?;
- const ssh = exec::cmd("ssh-keygen",
- "-Y", "sign", "-f", key, "-n", "file")?;
- const note = exec::cmd("git", "notes", "add", "-F", "-", newtag)?;
- exec::setenv(¬e, "GIT_NOTES_REF", "refs/notes/signatures/tar.gz");
-
- const pipe1 = unix::pipe()?;
- const pipe2 = unix::pipe()?;
- exec::addfile(&archive, pipe1.1, os::stdout_file);
- exec::addfile(&ssh, pipe1.0, os::stdin_file);
- exec::addfile(&ssh, pipe2.1, os::stdout_file);
- exec::addfile(¬e, pipe2.0, os::stdin_file);
- const archive = exec::start(&archive)?;
- const ssh = exec::start(&ssh)?;
- const note = exec::start(¬e)?;
- io::close(pipe1.0);
- io::close(pipe1.1);
- io::close(pipe2.0);
- io::close(pipe2.1);
- exec::check(&exec::wait(&archive)?)?;
- exec::check(&exec::wait(&ssh)?)?;
- exec::check(&exec::wait(¬e)?)?;
-
+ signtag(name, newtag, key)?;
fmt::printfln("Tagged {} version {}. "
"Use 'git push --follow-tags' to publish the new release.",
name, newtag)!;
@@ -259,6 +232,35 @@ fn choosekey() (str | release_error) = {
return path;
};
+fn signtag(name: str, tag: str, key: str) (void | release_error) = {
+ fmt::printfln("Using SSH key {} for release signature.", key)!;
+ const prefix = fmt::asprintf("--prefix={}-{}/", name, tag);
+ defer free(prefix);
+ const archive = exec::cmd("git", "archive",
+ "--format=tar.gz", prefix, tag)?;
+ const ssh = exec::cmd("ssh-keygen",
+ "-Y", "sign", "-f", key, "-n", "file")?;
+ const note = exec::cmd("git", "notes", "add", "-F", "-", tag)?;
+ exec::setenv(¬e, "GIT_NOTES_REF", "refs/notes/signatures/tar.gz");
+
+ const pipe1 = unix::pipe()?;
+ const pipe2 = unix::pipe()?;
+ exec::addfile(&archive, pipe1.1, os::stdout_file);
+ exec::addfile(&ssh, pipe1.0, os::stdin_file);
+ exec::addfile(&ssh, pipe2.1, os::stdout_file);
+ exec::addfile(¬e, pipe2.0, os::stdin_file);
+ const archive = exec::start(&archive)?;
+ const ssh = exec::start(&ssh)?;
+ const note = exec::start(¬e)?;
+ io::close(pipe1.0);
+ io::close(pipe1.1);
+ io::close(pipe2.0);
+ io::close(pipe2.1);
+ exec::check(&exec::wait(&archive)?)?;
+ exec::check(&exec::wait(&ssh)?)?;
+ exec::check(&exec::wait(¬e)?)?;
+};
+
fn git_runcmd(args: str...) (void | release_error) = {
const cmd = exec::cmd("git", args...)?;
const proc = exec::start(&cmd)?;