Skip to content

Commit

Permalink
chore: add a build script for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
krakozaure committed Jun 4, 2023
1 parent 5e73651 commit c7f689d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dist/
release/
tmpl
38 changes: 38 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c7f689d

Please sign in to comment.