From 301d107cd76f177fe1a7f3aa1d204294d0b6646f Mon Sep 17 00:00:00 2001 From: GINTOAHC Date: Sat, 5 Oct 2024 15:05:14 +0800 Subject: [PATCH] feat: release script --- .gitignore | 1 + release.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .gitignore create mode 100644 release.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..69ec3da --- /dev/null +++ b/release.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +VERSION=$(git describe --tags --abbrev=0) +BINARY="md-html" +BUILD_DIR="build" + +mkdir -p $BUILD_DIR + +PLATFORMS=("linux/amd64" "darwin/amd64" "darwin/arm64" "windows/amd64") + +for platform in "${PLATFORMS[@]}"; do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + + output_name=$BINARY + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + GOOS=$GOOS GOARCH=$GOARCH go build -o $BUILD_DIR/$output_name + tar -czf $BUILD_DIR/$BINARY-$VERSION-$GOOS-$GOARCH.tar.gz -C $BUILD_DIR $output_name + + echo "Build $BINARY-$VERSION-$GOOS-$GOARCH.tar.gz done" +done + +rm $BUILD_DIR/$BINARY +rm $BUILD_DIR/$BINARY.exe