curl

#!/bin/bash


# 驱动名字
driverName="GB_test_mhx"
# 平台
versionNo="v3.0.0"
version="official"

cd ..

staticCurl="curl --location --request POST "http://192.168.20.31/api/appStoreAdmin/drivers/file/upload"
--form "appFiles=@./$driverName"
--form "appName=$driverName" 
--form "versionNo=$versionNo" 
--form "version=$version"
--form "configFiles=@./pkg/config.json"
--form "configFiles=@./pkg/config.csv"
 "

# 参数: 1. 文件夹名字  2. 平台platform
funLib(){
	echo "编译的平台: ${2}"
	tmpCurl=$staticCurl
	if [ "$(ls -A $1)" ];then
	  echo "${1}文件夹存在"
		folder=$1

		softfiles=$(ls $folder)
		# 拼接平台
		tmpCurl="${tmpCurl} --form "platform=$2" "
		for sfile in ${softfiles}
				do
					tmpCurl="${tmpCurl} --form "configFiles=@${1}/${sfile}""
				done
		echo "拼接结果: ${tmpCurl}, and 开始传输给云平台"
		
	else
	  echo "${1}文件夹不存在"
		# 拼接平台
		tmpCurl="${tmpCurl} --form "platform=$2" "
		echo "拼接结果: ${tmpCurl}, and 开始传输给云平台"
	fi
	
	${tmpCurl}
}

# 编译amd64,并且发布到平台
rm -rf $driverName
xgo --targets=linux/amd64 -ldflags='-s -w'  -go go-1.16.4 -dest=. -pkg="." -out=$driverName .
cp ${driverName}-linux-amd64 $driverName
funLib "./linux-amd64" "linux-amd64"

# 编译386
rm -rf $driverName
xgo --targets=linux/386 -ldflags='-s -w'  -go go-1.16.4 -dest=. -pkg="." -out=$driverName .
cp ${driverName}-linux-386 $driverName
funLib "./linux-386" "linux-386"

# 编译arm5
rm -rf $driverName
xgo --targets=linux/arm-5 -ldflags='-s -w'  -go go-1.16.4 -dest=. -pkg="." -out=$driverName .
cp ${driverName}-linux-arm-5 $driverName
funLib "./linux-arm5" "linux-arm5"

# 编译arm6
rm -rf $driverName
xgo --targets=linux/arm-6 -ldflags='-s -w'  -go go-1.16.4 -dest=. -pkg="." -out=$driverName .
cp ${driverName}-linux-arm-6 $driverName
funLib "./linux-arm6" "linux-arm6"

# 编译arm7
rm -rf $driverName
xgo --targets=linux/arm-7 -ldflags='-s -w'  -go go-1.16.4 -dest=. -pkg="." -out=$driverName .
cp ${driverName}-linux-arm-7 $driverName
funLib "./linux-arm7" "linux-arm7"

原文地址:https://www.cnblogs.com/maomaomaoge/p/15791723.html