Skip to content

Commit

Permalink
Update: release building script
Browse files Browse the repository at this point in the history
  • Loading branch information
ssleert committed Feb 26, 2023
1 parent 19af770 commit f7416c6
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.2.1
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ssleert/zfxtop
go 1.18

require (
github.com/ssleert/ginip v0.0.0-20230216143908-88dd7fec65f8
github.com/ssleert/memory v0.0.0-20230216143742-eeb794db1c2d
github.com/ssleert/ginip v0.0.0-20230226084332-8b4abf96c4c9
github.com/ssleert/memory v0.0.0-20230226084404-d38f9dbae5c8
github.com/ssleert/sfolib v0.0.0-20230216145343-aaa0c738e5c0
github.com/ssleert/sterm v0.0.0-20230212222435-168aab76b00a
github.com/ssleert/sterm v0.0.0-20230226084438-89de735c6eaf
)

require (
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ github.com/ssleert/ginip v0.0.0-20230129095011-281b35abb363 h1:8KhzJiW7UkKFoYhCK
github.com/ssleert/ginip v0.0.0-20230129095011-281b35abb363/go.mod h1:kFrO03HveobMT8njoWS39u4ZlyeAJmR1JkS2hWDkIkM=
github.com/ssleert/ginip v0.0.0-20230216143908-88dd7fec65f8 h1:E5CYH2DQnRbvdHvPtB6As32m4wXRU+HErLM1oplZnMA=
github.com/ssleert/ginip v0.0.0-20230216143908-88dd7fec65f8/go.mod h1:eHLy0WJhTsxRJrVKcysV7FwJmKtf8aO9qFhr52Z4sJA=
github.com/ssleert/ginip v0.0.0-20230226084332-8b4abf96c4c9 h1:j3KQcyIswz846vN2fQg3+Dowm5L2xd7oc51XBDDb2nA=
github.com/ssleert/ginip v0.0.0-20230226084332-8b4abf96c4c9/go.mod h1:G3jty3FAZ+/siAPVRU5LkzlW9M1jgv8LTSEuPSgO1nw=
github.com/ssleert/memory v0.0.0-20230103231353-e1d09fb8d47b h1:2pAOrnJYvnCuHiTKGV818BXd7QlCNdVXulzul1vx4Jg=
github.com/ssleert/memory v0.0.0-20230103231353-e1d09fb8d47b/go.mod h1:8la+hPQ08C+pYCShvQB24O1KEfw223INgrf3vZ42GGg=
github.com/ssleert/memory v0.0.0-20230211074400-a351b7312fc4 h1:Gm21fWGaiKVg4yTiStfERNFrjRQ+B5/qe/wkPiZdPF8=
github.com/ssleert/memory v0.0.0-20230211074400-a351b7312fc4/go.mod h1:8la+hPQ08C+pYCShvQB24O1KEfw223INgrf3vZ42GGg=
github.com/ssleert/memory v0.0.0-20230216143742-eeb794db1c2d h1:bYbz5VIy1qWhAVedIXOnICbSKbzKy+1m+XKnFyrysaY=
github.com/ssleert/memory v0.0.0-20230216143742-eeb794db1c2d/go.mod h1:ohtjMjL7DPi8Yu09tfg3poS9evouRia8resAsp/VOzA=
github.com/ssleert/memory v0.0.0-20230226084404-d38f9dbae5c8 h1:GLlcS5Yqp6Tvr78p2ASuCvgTgFik/f5J87pG6YNi1LI=
github.com/ssleert/memory v0.0.0-20230226084404-d38f9dbae5c8/go.mod h1:qvtv/pPP8it5AaBnZ1nAMw+T5L8WUpP9zWKoT/415p4=
github.com/ssleert/sfolib v0.0.0-20230203143112-9ac4d7201928 h1:PYpQfxD90NxhIss/tEHrNbF2Rwa9R29kBDnt1gCY3Z8=
github.com/ssleert/sfolib v0.0.0-20230203143112-9ac4d7201928/go.mod h1:/9/wK9KIObc44RFZLx93S8vFbGLUG34vh48fB7NNAD4=
github.com/ssleert/sfolib v0.0.0-20230216145343-aaa0c738e5c0 h1:z/fbWmleWo0KNKpXz9AY09rC3lNMgx+Fy3/p9ZI7vpE=
Expand All @@ -20,6 +24,8 @@ github.com/ssleert/sterm v0.0.0-20230212212335-5900e034f674 h1:5jXVNKllpJuelKeye
github.com/ssleert/sterm v0.0.0-20230212212335-5900e034f674/go.mod h1:bVZzi9tuQ8EOgtaHC53nCoUFCwBLLRVtCm9+DRwpcG8=
github.com/ssleert/sterm v0.0.0-20230212222435-168aab76b00a h1:CnB51PeY4DrMf0rByEfFoZX78zPK1DsXqQWnTaCstTw=
github.com/ssleert/sterm v0.0.0-20230212222435-168aab76b00a/go.mod h1:bVZzi9tuQ8EOgtaHC53nCoUFCwBLLRVtCm9+DRwpcG8=
github.com/ssleert/sterm v0.0.0-20230226084438-89de735c6eaf h1:SyYDHVofnSkptHRgj6CpLOdOdzWuSqrBIxo/zVsUnEE=
github.com/ssleert/sterm v0.0.0-20230226084438-89de735c6eaf/go.mod h1:dkEW/d0LsWgsBoWr6x0wdUa1HxJfsqHvXWrJ0BuaqVs=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
Expand Down
2 changes: 1 addition & 1 deletion internal/self/commit.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58b8ac7
19af770
2 changes: 1 addition & 1 deletion internal/self/version.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.2.1
9 changes: 8 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
CGO_ENABLED=0 go build -ldflags="-s -w" -gcflags=all="-B -C" cmd/zfxtop/zfxtop.go
CGO_ENABLED=0

main() {
generate
go build -ldflags="-s -w" -gcflags=all="-B -C" cmd/zfxtop/zfxtop.go
}

main
8 changes: 6 additions & 2 deletions scripts/contribute.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
go fmt ./...
go generate ./...
main() {
format
generate
}

main
49 changes: 49 additions & 0 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export CLR_RESET='\033[1;0m'
export STL_BOLD='\033[1;1m'
export CLR_RED='\033[0;31m'
export CLR_GREEN='\033[0;32m'
export CLR_BLUE='\033[0;34m'

has() {
_cmd=$(command -v "$1") 2> /dev/null || return 1
[ -x "$_cmd" ] || return 1
}

msg() {
printf "${CLR_BLUE}${STL_BOLD}::${CLR_RESET} ${STL_BOLD}%s${CLR_RESET}\n" "$1"
shift
for i in "$@"; do
printf " ${CLR_BLUE}${STL_BOLD}|${CLR_RESET} ${STL_BOLD}%s${CLR_RESET}\n" "$i"
done
}

compl() {
printf "${CLR_GREEN}${STL_BOLD}>>>${CLR_RESET} ${STL_BOLD}%s${CLR_RESET}\n" "$1"
shift
for i in "$@"; do
printf " ${CLR_GREEN}${STL_BOLD}|${CLR_RESET} ${STL_BOLD}%s${CLR_RESET}\n" "$i"
done
}

err() {
printf "${CLR_RED}${STL_BOLD}error:${CLR_RESET} ${STL_BOLD}%s${CLR_RESET}\n" "$1"
shift
for i in "$@"; do
printf " ${CLR_RED}${STL_BOLD}|${CLR_RESET} ${STL_BOLD}%s${CLR_RESET}\n" "$i"
done
}

die() {
err "$@"
exit 1
}

generate() {
go generate ./...
compl "files generated"
}

format() {
go fmt ./...
compl "files formated"
}
82 changes: 79 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,82 @@
#!/bin/sh
. "scripts/lib.sh"

CGO_ENABLED=0
NAME='zfxtop'
VERSION="$(cat VERSION)"
RELEASE='./release'
BDIR="${RELEASE}/bin"
PDIR="${RELEASE}/pkg"

ARCHES='
386
amd64
'
OSES='
linux
'

go generate ./...
GOARCH=386 go build -ldflags="-s -w" -gcflags=all="-B -C" -o "release/zfxtop_386" cmd/zfxtop/zfxtop.go
GOARCH=amd64 go build -ldflags="-s -w" -gcflags=all="-B -C" -o "release/zfxtop_amd64" cmd/zfxtop/zfxtop.go
# sorry but now without arm support(

clear() {
[ -d "$RELEASE" ] && {
rm -r "$RELEASE"
msg "'$RELEASE' dir removed"
}

mkdir "$RELEASE"
msg "'$RELEASE' dir created"
}

compile() {
mkdir "$BDIR"
msg "'$BDIR' created"

for arch in $ARCHES; do
for os in $OSES; do
GOARCH="$arch" GOOS="$os" go build -ldflags="-s -w" -gcflags=all="-B -C" -o "${BDIR}/${NAME}_${VERSION}_${os}_${arch}" "cmd/${NAME}/${NAME}.go"
[ $? -ne 0 ] && {
die "exeption during compilation"
}
msg "'${BDIR}/${NAME}_${VERSION}_${os}_${arch}' builded"
done
done
compl "all executables builded"
}

package() {
mkdir "$PDIR"
msg "'$PDIR' created"

for arch in $ARCHES; do
for os in $OSES; do
tar -czf "${PDIR}/${NAME}_${VERSION}_${os}_${arch}.tar.gz" "${BDIR}/${NAME}_${VERSION}_${os}_${arch}"
[ $? -ne 0 ] && {
die "exeption during packaging"
}
msg "'${PDIR}/${NAME}_${VERSION}_${os}_${arch}.tar.gz' packaged"
done
done
compl "all executables packaged"
}

gen_checksum() {
cd "$PDIR"
msg "dir changed to '$PDIR'"
sha256sum *.tar.gz > checksums.txt
compl "checksums for '$PDIR' generated"
cd "../../"
msg "dir chenged to '$PWD'"
}

main() {
clear
format
generate
compile
package
gen_checksum
compl "ALL COMPLETED"
}

main

0 comments on commit f7416c6

Please sign in to comment.