lith 3 years ago
parent
commit
39ba852937

+ 5 - 0
FileZip/FileZip.csproj

@@ -1,5 +1,10 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
+	<PropertyGroup>
+		<publish>FileZip</publish>
+		<docker>filezip</docker>
+	</PropertyGroup>
+
 	<PropertyGroup>
 		<OutputType>Exe</OutputType>
 		<TargetFramework>netcoreapp2.1</TargetFramework>

+ 0 - 22
Publish/20.一键发布.bat

@@ -1,22 +0,0 @@
-:: @echo off
-
-cd /d 脚本\发布脚本 
-
-:: 并行发布
-:: for /R %%s in (发布-*) do (   
-::  start "发布" "%%s"
-:: )  
-
-:: 串行发布
-for /R %%s in (发布-*) do (   
- call "%%s"
-)  
-
-cd /d ..\制作docker镜像
-call "docker镜像-1.复制文件.bat"
-
-echo 发布完成
-echo 发布完成
-echo 发布完成
-
-:: pause

+ 0 - 8
Publish/21.一键删除发布文件.bat

@@ -1,8 +0,0 @@
- 
-rd /s/q "04.服务站点/FileZip"
-
-
-cd /d 脚本/制作docker镜像
-call "docker镜像-2.删除文件.bat"
-cd /d ../..
- 

+ 0 - 84
Publish/DevOps/github/20.docker-build.sh

@@ -1,84 +0,0 @@
-set -e
-
-
-#---------------------------------------------------------------------
-#(x.1)参数
-args_="
-
-export codePath=/root/docker/jenkins/workspace/sqler/svn 
-
-
-
-export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
-
-export name=sqler
-export projectPath=Sqler
-
-export DOCKER_USERNAME=serset
-export DOCKER_PASSWORD=xxx
-
-# "
-
- 
-
-
-#---------------------------------------------------------------------
-echo "(x.2)dotnet-构建并发布项目文件"
-
-docker run -i --rm \
---env LANG=C.UTF-8 \
--v $codePath:/root/code \
-serset/dotnet:6.0-sdk \
-bash -c "
-cd '/root/code/$projectPath'
-dotnet build --configuration Release
-dotnet publish --configuration Release --output '/root/code/Publish/06.Docker/制作镜像/$name/app' " 
-
-
-
-
-
-#---------------------------------------------------------------------
-#(x.3.1)docker-初始化多架构构建器
-
-#启用 buildx 插件
-export DOCKER_CLI_EXPERIMENTAL=enabled
-
-#验证是否开启
-docker buildx version
-
-#启用 binfmt_misc
-docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
-
-#验证是 binfmt_misc 否开启
-ls -al /proc/sys/fs/binfmt_misc/
-
-
-#创建一个新的构建器
-docker buildx create --use --name mybuilder
-
-#启动构建器
-docker buildx inspect mybuilder --bootstrap
-
-#查看当前使用的构建器及构建器支持的 CPU 架构,可以看到支持很多 CPU 架构:
-docker buildx ls
-
-
-
-#---------------------------------------------------------------------
-#(x.3.2)docker-构建多架构镜像( arm、arm64 和 amd64 )并推送到 Docker Hub
-
-docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
-
-docker buildx build $codePath/Publish/06.Docker/制作镜像/$name -t $DOCKER_USERNAME/$name:$version -t $DOCKER_USERNAME/$name --platform=linux/amd64,linux/arm64,linux/arm/v7 --push
- 
-
-
-
-
- 
-
-
-
-
- 

+ 67 - 0
Publish/DevOps/github/40.dotnet-publish.sh

@@ -0,0 +1,67 @@
+set -e
+
+
+#---------------------------------------------------------------------
+#(x.1)参数
+args_="
+
+export codePath=/root/temp/svn
+
+
+export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
+
+
+
+# "
+
+ 
+
+#----------------------------------------------
+echo "(x.2)dotnet-publish"
+echo "dotnet version: ${netVersion}"
+
+docker run -i --rm \
+--env LANG=C.UTF-8 \
+-v $codePath:/root/code \
+serset/dotnet:6.0-sdk \
+bash -c "
+set -e
+
+publishPath=/root/code/Publish/release/Sers/SersPublish/$netVersion
+
+#(x.3)查找所有需要发布的项目并发布
+cd /root/code/dotnet
+for file in \$(grep -a '<publish>' . -rl --include *.csproj)
+do
+	cd /root/code/dotnet
+	
+	#get name
+	name=\`grep '<publish>' \$file -r | grep -oP '>(.*)<' | tr -d '<>'\`
+	echo publish \$name
+
+	#publish
+	cd \$(dirname \"\$file\")
+	dotnet build --configuration Release
+	dotnet publish --configuration Release --output \$publishPath/\$name
+
+	#copy xml
+	for filePath in bin/Release/$netVersion/*.xml ; do \\cp -rf \$filePath \$publishPath/\$name;done
+done
+
+
+#(x.4)copy bat
+\\cp -rf /root/code/Publish/PublishFile/SersPublish/. \$publishPath
+
+
+"
+
+
+
+
+echo 'publish succeed!'
+
+
+
+
+
+

+ 7 - 7
Publish/DevOps/github/startup.sh → Publish/DevOps/github/startup.bash

@@ -1,5 +1,7 @@
 set -e
 
+# cd /root/temp/svn/Publish/DevOps/github;bash startup.bash;
+
 #----------------------------------------------
 #(x.1)当前路径 
 curWorkDir=$PWD
@@ -9,10 +11,11 @@ export codePath=$PWD
 cd $curWorkDir
 
 
+# export codePath=/root/temp/svn
+
 export name=filezip
 export projectPath=FileZip
 
-
 #export DOCKER_USERNAME=serset
 #export DOCKER_PASSWORD=xxx
 
@@ -42,12 +45,9 @@ echo "(x.3)自动发布 $name-$version"
 
 for file in *.sh
 do
-    if [[ $file != "startup.sh" ]]
-    then
-        echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-        echo bash $file
-        bash $file
-    fi
+    echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    echo bash $file
+    bash $file
 done
 
 

+ 0 - 0
Publish/06.Docker/制作镜像/filezip/Dockerfile → Publish/ReleaseFile/docker-image/filezip/Dockerfile


+ 0 - 0
Publish/06.Docker/制作镜像/制作镜像.txt → Publish/ReleaseFile/docker-image/制作镜像.txt


+ 0 - 0
Publish/04.服务站点/Start FileZip.bat → Publish/ReleaseFile/publish/Start FileZip.bat


+ 45 - 0
Publish/cmd/docker-image-create.bat

@@ -0,0 +1,45 @@
+@echo off
+
+::启用变量延迟
+setlocal EnableDelayedExpansion
+
+
+echo %~n0.bat start...
+
+
+::(x.1)获取basePath
+set curPath=%cd%
+cd /d "%~dp0"
+cd /d ../..
+set basePath=%cd%
+set publishPath=%basePath%/Publish/release/release/publish
+set dockerPath=%basePath%/Publish/release/release/docker-image
+
+
+rd /s /q "%dockerPath%"
+
+::(x.2)copy bat
+xcopy "%basePath%/Publish/ReleaseFile/docker-image" "%dockerPath%" /e /i /r /y
+
+
+
+::(x.3)查找所有需要发布的项目并发布
+for /f "delims=" %%f in ('findstr /M /s /i "<docker>" *.csproj') do (
+	::get publishName
+	for /f "tokens=3 delims=><" %%a in ('type "%basePath%\%%f"^|findstr "<publish>.*publish"') do set publishName=%%a
+	::get dockerName
+	for /f "tokens=3 delims=><" %%a in ('type "%basePath%\%%f"^|findstr "<docker>.*docker"') do set dockerName=%%a
+
+	echo create !dockerName!
+
+	::copy file
+	xcopy "%publishPath%/!publishName!" "%dockerPath%/!dockerName!/app" /e /i /r /y
+)
+
+
+
+
+
+echo %~n0.bat 执行成功!
+
+cd /d "%curPath%"

+ 49 - 0
Publish/cmd/dotnet-publish.bat

@@ -0,0 +1,49 @@
+@echo off
+
+::启用变量延迟
+setlocal EnableDelayedExpansion
+
+
+echo %~n0.bat start...
+
+
+::(x.1)获取basePath
+set curPath=%cd%
+cd /d "%~dp0"
+cd /d ../..
+set basePath=%cd%
+set publishPath=%basePath%/Publish/release/release/publish
+
+
+
+
+::(x.2)查找所有需要发布的项目并发布
+for /f "delims=" %%f in ('findstr /M /s /i "<publish>" *.csproj') do (
+	::get publishName
+	for /f "tokens=3 delims=><" %%a in ('type "%basePath%\%%f"^|findstr "<publish>.*publish"') do set publishName=%%a
+	echo publish !publishName!
+
+	::publish
+	cd /d "%basePath%\%%f\.."
+	dotnet build --configuration Release
+	dotnet publish --configuration Release --output "%publishPath%\!publishName!"
+	@if errorlevel 1 (echo . & echo .  & echo 出错,请排查!& pause) 
+)
+
+
+
+
+
+
+::(x.3)copy bat
+xcopy "%basePath%\Publish\ReleaseFile\publish" "%publishPath%" /e /i /r /y
+
+
+
+
+
+
+
+echo %~n0.bat 执行成功!
+
+cd /d "%curPath%"

+ 8 - 0
Publish/cmd/一键发布.bat

@@ -0,0 +1,8 @@
+
+call "dotnet-publish.bat"
+
+call "docker-image-create.bat"
+
+echo %~n0.bat Ö´ĐĐłÉšŚŁĄ
+
+pause

+ 1 - 0
Publish/cmd/清理-发布文件.bat

@@ -0,0 +1 @@
+rd /s/q ..\release

+ 0 - 6
Publish/脚本/制作docker镜像/docker镜像-1.复制文件.bat

@@ -1,6 +0,0 @@
-echo '复制文件'
-
-::制作镜像
-xcopy "..\..\04.服务站点\FileZip"  "..\..\06.Docker\制作镜像\filezip\app"  /e /i /r /y
-
-

+ 0 - 4
Publish/脚本/制作docker镜像/docker镜像-2.删除文件.bat

@@ -1,4 +0,0 @@
-echo 'ɾ³ıÎļş'
- 
-
-rd /s/q "..\..\06.Docker\ÖÆ×÷¾µÏñ\filezip\app"

+ 0 - 8
Publish/脚本/发布脚本/发布-02.FileZip.bat

@@ -1,8 +0,0 @@
- 
-cd /d ..\..\..\FileZip
-dotnet build --configuration Release
-dotnet publish --configuration Release --output ..\Publish\04.·þÎñÕ¾µã\FileZip
-cd /d ..\Publish\½Å±¾\·¢²¼½Å±¾
-
- 
-