~hristoast/mousikofidi

a5bab91b0e79c71dbbdebbe9a0c25b275ada8077 — Hristos N. Triantafillou 7 days ago fddc046
Better packaing
2 files changed, 34 insertions(+), 9 deletions(-)

M Makefile
M package.sh
M Makefile => Makefile +8 -5
@@ 1,6 1,6 @@
proj_dir := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

.DEFAULT_GOAL:= build
.DEFAULT_GOAL:= pkg

build: build-cli-all build-server-all



@@ 12,7 12,7 @@ build-cli-linux-amd64:
	cd $(proj_dir) && GOPATH=$$HOME/.local/go GOOS=linux GOARCH=amd64 go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags="-linkmode=external -s -w -X 'git.sr.ht/~hristoast/mousikofidi/cfg.Version=$$(git describe --tags)'" -o ./mousikofidi-cli-linux-amd64 ./cmd/mousikofidi-cli

build-cli-linux-arm64:
	cd $(proj_dir) && GOPATH=$$HOME/.local/go GOOS=linux GOARCH=arm64 go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags="-s -w -X 'git.sr.ht/~hristoast/mousikofidi/cfg.Version=$$(git describe --tags)'" -o ./mousikofidi-cli-linux-amd64 ./cmd/mousikofidi-cli
	cd $(proj_dir) && GOPATH=$$HOME/.local/go GOOS=linux GOARCH=arm64 go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags="-s -w -X 'git.sr.ht/~hristoast/mousikofidi/cfg.Version=$$(git describe --tags)'" -o ./mousikofidi-cli-linux-arm64 ./cmd/mousikofidi-cli

build-cli-windows-amd64:
	cd $(proj_dir) && GOPATH=$$HOME/.local/go GOOS=windows GOARCH=amd64 go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags="-s -w -X 'git.sr.ht/~hristoast/mousikofidi/cfg.Version=$$(git describe --tags)'" -o ./mousikofidi-cli.exe ./cmd/mousikofidi-cli


@@ 26,13 26,16 @@ build-server-linux-arm64:
build-server-windows-amd64:
	cd $(proj_dir) && GOPATH=$$HOME/.local/go GOOS=windows GOARCH=amd64 go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags="-s -w -X 'git.sr.ht/~hristoast/mousikofidi/cfg.Version=$$(git describe --tags)'" -o ./mousikofidi-server.exe ./cmd/mousikofidi

clean: clean-server
clean: clean-cli clean-server

clean-cli:
	cd $(proj_dir) && rm -f mousikofidi-cli-*-* mousikofidi-cli.exe
	cd $(proj_dir) && rm -f mousikofidi-cli-*-* mousikofidi-cli.*

clean-server:
	cd $(proj_dir) && rm -f mousikofidi-server-*-* mousikofidi-server.exe
	cd $(proj_dir) && rm -f mousikofidi-server-*-* mousikofidi-server.*

pkg: clean build
	cd $(proj_dir) && ./package.sh

run:
	cd $(proj_dir) && GOPATH=$$HOME/.local/go go run ./cmd/mousikofidi

M package.sh => package.sh +26 -4
@@ 1,6 1,28 @@
#!/usr/bin/env bash
set -eux -o pipefail
set -eu -o pipefail

gzip mousikofidi-server-linux-amd64
gzip mousikofidi-server-linux-arm64
zip -r mousikofidi-server.zip mousikofidi-server.exe
linux=(
    mousikofidi-cli-linux-amd64
    mousikofidi-cli-linux-arm64
    mousikofidi-server-linux-amd64
    mousikofidi-server-linux-arm64
)

windows=(
    mousikofidi-cli.exe
    mousikofidi-server.exe
)

for l in "${linux[@]}"; do
    sha256sum ${l} > ${l}.sha256.txt
    sha512sum ${l} > ${l}.sha512.txt
    tar czpf ${l}.tar.gz ${l}.sha256.txt ${l}.sha512.txt ${l}
done

for w in "${windows[@]}"; do
    sha256sum ${w} > ${w}.sha256.txt
    sha512sum ${w} > ${w}.sha512.txt
    zip -qr $(echo ${w} | sed "s|\\.exe||").zip ${w}.sha256.txt ${w}.sha512.txt ${w}
done

rm -f *.sha*.txt