From c7f689db0061a2d3f096fe97f73cc9000c15fd10 Mon Sep 17 00:00:00 2001 From: krako Date: Sun, 4 Jun 2023 05:00:07 +0200 Subject: [PATCH] chore: add a build script for releases --- .gitignore | 2 +- build | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 build diff --git a/.gitignore b/.gitignore index df51db1..c8b8955 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -dist/ +release/ tmpl diff --git a/build b/build new file mode 100755 index 0000000..91bda59 --- /dev/null +++ b/build @@ -0,0 +1,38 @@ +#!/bin/sh + +set -eu + +prog_name="$(basename "$PWD")" +build_dir="./release" +export GOARCH=amd64 + +declare -A build_files +build_files[darwin]="${prog_name}-darwin_${GOARCH}" +build_files[linux]="${prog_name}-linux_${GOARCH}" +build_files[windows]="${prog_name}-windows_${GOARCH}.exe" + +rm -fr -- "${build_dir}" +mkdir -p -- "${build_dir}" + +printf '\e[34m-> Building\e[0m\n' +for os in ${!build_files[@]}; do + f="${build_files[$os]}" + echo " - $f" + GOOS="${os}" go build -ldflags='-s -w' -o "${build_dir}/$f" +done + +cd -- "${build_dir}" + +printf '\e[34m-> Generating checksums\e[0m\n' +for os in ${!build_files[@]}; do + f="${build_files[$os]}" + echo " - $f" + sha256sum "$f" >> "$f.sha256" +done + +printf '\e[34m-> Generating signatures\e[0m\n' +for os in ${!build_files[@]}; do + f="${build_files[$os]}" + echo " - $f" + gpg --quiet --yes --default-key Krakozaure --output "$f.sha256.sig" --detach-sign "$f.sha256" +done