소스 검색

Add OSs, architectures, MPLv2 license exhibits

Jonathan D. Storm 10 달 전
부모
커밋
09493341cb
4개의 변경된 파일61개의 추가작업 그리고 6개의 파일을 삭제
  1. 44 0
      build.sh
  2. 12 1
      main.go
  3. 5 0
      main_test.go
  4. 0 5
      release.go

+ 44 - 0
build.sh

@@ -0,0 +1,44 @@
+#/bin/bash
+
+set -euo pipefail
+
+
+function build() {
+	export GOOS=$1
+	export GOARCH=$2
+
+	local artifact=dump2sql-$GOOS-$GOARCH
+
+	if [ $GOOS == windows ]
+	then artifact=$artifact.exe
+	fi
+
+	go build \
+	-o $artifact \
+	-buildmode pie \
+	-ldflags "\
+		-w -s \
+		-X main.Version=$(git describe --tags | head -1) \
+		-X main.Build=$(date --utc --iso-8601=s)"
+
+	sha256sum ./$artifact > $artifact.sha256sum
+}
+
+function main() {
+	local -r targets="linux amd64
+		linux arm64
+		darwin amd64
+		darwin arm64
+		windows amd64"
+
+	local -a target
+	while read line
+	do
+		read -a target <<< $line
+		build ${target[0]} ${target[1]}
+	done < <(echo "$targets")
+}
+
+
+main $@
+

+ 12 - 1
main.go

@@ -1,3 +1,8 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ */
 package main
 
 import (
@@ -18,10 +23,16 @@ import (
 	"golang.org/x/term"
 )
 
-var MaxRecords = 1_000_000_000
+var (
+	Version string
+	Build   string
+)
+
+const MaxRecords = 1_000_000_000
 
 func main() {
 	if len(os.Args) != 2 {
+		log.Printf("%s %s", Version, Build)
 		log.Printf("usage: %s <csv_path>", os.Args[0])
 		os.Exit(1)
 	}

+ 5 - 0
main_test.go

@@ -1,3 +1,8 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ */
 package main
 
 import (

+ 0 - 5
release.go

@@ -1,5 +0,0 @@
-//go:build release
-
-//go:generate go build -buildmode pie -gcflags "-m" -ldflags "-w -s"
-
-package main