lith преди 3 години
родител
ревизия
83cd13706c

+ 63 - 0
.github/workflows/action-main.yml

@@ -0,0 +1,63 @@
+# This is a basic workflow to help you get started with Actions
+
+name: CI
+
+# Controls when the action will run. 
+on:
+  # Triggers the workflow on push tag
+  push:
+    tags:
+      - '*'
+
+  # Allows you to run this workflow manually from the Actions tab
+  workflow_dispatch:
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+  # This workflow contains a single job called "build"
+  build:
+    # The type of runner that the job will run on
+    runs-on: ubuntu-latest
+
+    # Steps represent a sequence of tasks that will be executed as part of the job
+    steps:
+      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+      - uses: actions/checkout@v2
+
+      # Runs a set of commands using the runners shell
+      - name: Run startup.sh
+        run: |
+           set -e
+           echo start build
+           export DOCKER_USERNAME="${{ secrets.DOCKER_USERNAME  }}"
+           export DOCKER_PASSWORD="${{ secrets.DOCKER_PASSWORD }}"
+           export NUGET_SERVER="${{ secrets.NUGET_SERVER  }}"
+           export NUGET_KEY="${{ secrets.NUGET_KEY }}"
+           export GIT_SSH_SECRET="${{ secrets.GIT_SSH_SECRET }}"
+           cd ./dotnet/Doc/DevOps/github
+           bash startup.sh
+           echo build succeed!
+
+      - name: Release-Create
+        id: create_release
+        uses: actions/create-release@v1
+        if: hashFiles(env.release_assetPath)
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          release_name: ${{ env.release_name }}
+          tag_name: ${{ env.release_tag }}
+          draft: ${{ env.Release_draft }}
+          prerelease: ${{ env.release_prerelease }}
+          body: ${{ env.release_body }}
+      - name: Release-Upload
+        id: upload-release-asset
+        uses: actions/upload-release-asset@v1
+        if: hashFiles(env.release_assetPath)
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a   `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
+          asset_path: ${{ env.release_assetPath }}
+          asset_name: ${{ env.release_assetName }}
+          asset_content_type: ${{ env.release_contentType }}

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

@@ -0,0 +1,84 @@
+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
+ 
+
+
+
+
+ 
+
+
+
+
+ 

+ 50 - 0
dotnet/Doc/DevOps/github/30.nuget-build.sh

@@ -0,0 +1,50 @@
+set -e
+
+# bash 30.nuget-build.sh
+
+
+#---------------------------------------------------------------------
+#(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=Vit.Ioc
+export projectPath=Vit.Ioc
+
+export NUGET_SERVER=https://api.nuget.org/v3/index.json
+export NUGET_KEY=xxxxxxxxxx
+
+# "
+
+ 
+ 
+
+
+ 
+
+#----------------------------------------------
+echo "(x.2)nuget-构建包并推送到nuget server"
+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 pack --configuration Release --output '/root/code/Publish/nuget'
+
+# push to nuget server
+for file in /root/code/Publish/nuget/*.nupkg ; 
+do
+    echo nuget push \$file
+    dotnet nuget push \$file -k ${NUGET_KEY} -s ${NUGET_SERVER}
+done
+" 
+
+
+
+

+ 76 - 0
dotnet/Doc/DevOps/github/90.release-build.sh

@@ -0,0 +1,76 @@
+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 export GIT_SSH_SECRET=xxxxxx
+
+# "
+
+ 
+
+
+
+#----------------------------------------------
+echo "(x.2.1)发布文件-创建文件夹及内容"
+mkdir -p $codePath/Publish/git
+mkdir -p $codePath/Publish/release
+
+cp -rf  $codePath/Publish/04.服务站点 $codePath/Publish/release/04.服务站点
+cp -rf  $codePath/Publish/06.Docker $codePath/Publish/release/06.Docker
+cp -rf  $codePath/Publish/06.Docker/制作镜像/${name}/app $codePath/Publish/release/04.服务站点/${name}
+
+
+echo "(x.2.3)发布文件-压缩" 
+docker run --rm -i \
+-v $codePath/Publish:/root/file \
+serset/filezip dotnet FileZip.dll zip -i /root/file/release -o /root/file/git/${name}-${version}.zip
+
+ 
+
+
+
+
+
+
+#----------------------------------------------
+echo "(x.3)github-提交release文件到release仓库"
+# releaseFile=$codePath/Publish/git/${name}-${version}.zip
+
+#复制ssh key
+echo "${GIT_SSH_SECRET}" > $codePath/Publish/git/serset
+chmod 600 $codePath/Publish/git/serset
+
+#推送到github
+docker run -i --rm -v $codePath/Publish/git:/root/git serset/git-client bash -c " \
+set -e
+ssh-agent bash -c \"
+ssh-add /root/git/serset
+ssh -T git@github.com -o StrictHostKeyChecking=no
+git config --global user.email 'serset@yeah.com'
+git config --global user.name 'lith'
+mkdir -p /root/code
+cd /root/code
+git clone git@github.com:serset/release.git /root/code
+mkdir -p /root/code/file/${name}
+cp /root/git/${name}-${version}.zip /root/code/file/${name}
+git add file/${name}/${name}-${version}.zip
+git commit -m 'auto commit ${version}'
+git push -u origin master \" "
+
+
+
+
+
+ 
+ 

+ 48 - 0
dotnet/Doc/DevOps/github/91.release-github.sh

@@ -0,0 +1,48 @@
+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
+
+# "
+
+
+ 
+
+
+#---------------------------------------------------------------------
+#(x.2)初始化github release环境变量
+# releaseFile=$codePath/Publish/git/${name}-${version}.zip
+
+filePath="$codePath/Publish/git/${name}-${version}.zip"
+#name=Vit.Library
+#version=2.5
+
+
+
+fileType="${filePath##*.}"
+echo "release_name=${name}-${version}" >> $GITHUB_ENV
+echo "release_tag=${version}" >> $GITHUB_ENV
+
+echo "release_draft=false" >> $GITHUB_ENV
+echo "release_prerelease=false" >> $GITHUB_ENV
+
+echo "release_body=" >> $GITHUB_ENV
+
+echo "release_assetPath=${filePath}" >> $GITHUB_ENV
+echo "release_assetName=${name}-${version}.${fileType}" >> $GITHUB_ENV
+echo "release_contentType=application/${fileType}" >> $GITHUB_ENV
+
+
+
+
+ 

+ 59 - 0
dotnet/Doc/DevOps/github/startup.sh

@@ -0,0 +1,59 @@
+set -e
+
+#----------------------------------------------
+#(x.1)当前路径 
+curWorkDir=$PWD
+
+cd $curWorkDir/../../..
+export codePath=$PWD
+cd $curWorkDir
+
+
+
+export name=sqler
+export projectPath=Sqler
+
+#export DOCKER_USERNAME=serset
+#export DOCKER_PASSWORD=xxx
+
+#export NUGET_SERVER=https://api.nuget.org/v3/index.json
+#export NUGET_KEY=xxxxxxxxxx
+
+#export export GIT_SSH_SECRET=xxxxxx
+
+
+
+
+
+
+#----------------------------------------------
+echo "(x.2)get version" 
+export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
+# echo $version
+
+
+
+
+
+
+
+#----------------------------------------------
+echo "(x.3)自动发布 $name-$version"
+
+for file in *.sh
+do
+    if [[ $file != "startup.sh" ]]
+    then
+        sh $file
+    fi
+done
+
+
+
+
+
+
+ 
+#----------------------------------------------
+#(x.9)
+#cd $curWorkDir

+ 2 - 2
dotnet/Doc/DevOps/00.svn-checkout.sh → dotnet/Doc/DevOps/k8s/00.svn-checkout.sh

@@ -1,13 +1,13 @@
 set -e
 
-# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps; bash 00.svn-checkout.sh
+# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps/k8s; bash 00.svn-checkout.sh
 
 
 #(x.1)当前路径
 curWorkDir=$PWD
 curPath=$(dirname $0)
 
-cd $curPath/..
+cd $curPath/../..
 basePath=$PWD
 # basePath=/home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers
 

+ 2 - 2
dotnet/Doc/DevOps/01.svn-update.sh → dotnet/Doc/DevOps/k8s/01.svn-update.sh

@@ -1,6 +1,6 @@
 set -e
 
-# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps; bash 01.svn-update.sh
+# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps/k8s; bash 01.svn-update.sh
 
 
 
@@ -9,7 +9,7 @@ set -e
 curWorkDir=$PWD
 curPath=$(dirname $0)
 
-cd $curPath/../../../..
+cd $curPath/../../../../..
 codePath=$PWD
 # codePath=/home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code
 

+ 2 - 2
dotnet/Doc/DevOps/10.code-changeVersion.sh → dotnet/Doc/DevOps/k8s/10.code-changeVersion.sh

@@ -1,13 +1,13 @@
 set -e
 
-# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps; bash 10.changeVersion.sh
+# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps/k8s; bash 10.changeVersion.sh
 
 
 #(x.1)当前路径
 curWorkDir=$PWD
 curPath=$(dirname $0)
 
-cd $curPath/../../../..
+cd $curPath/../../../../..
 codePath=$PWD 
 # codePath=/home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code
 

+ 2 - 2
dotnet/Doc/DevOps/20.nuget-publish-main.sh → dotnet/Doc/DevOps/k8s/20.nuget-publish-main.sh

@@ -1,13 +1,13 @@
 set -e
 
-# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps; bash 20.nuget-publish-main.sh
+# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps/k8s; bash 20.nuget-publish-main.sh
 
 
 #(x.1)当前路径
 curWorkDir=$PWD
 curPath=$(dirname $0)
 
-cd $curPath/../../../../..
+cd $curPath/../../../../../..
 basePath=$PWD
  
 # basePath=/home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers

+ 0 - 0
dotnet/Doc/DevOps/21.nuget-publish.sh → dotnet/Doc/DevOps/k8s/21.nuget-publish.sh


+ 1 - 1
dotnet/Doc/DevOps/99.jenkins.sh → dotnet/Doc/DevOps/k8s/99.jenkins.sh

@@ -1,7 +1,7 @@
 set -e
 
 
-# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps; bash 99.jenkins.sh
+# cd /home/DataStore/HDD/Data/008.jenkins/data/PersistentVolume/workspace/Sers/code/Sers/dotnet/Doc/DevOps/k8s; bash 99.jenkins.sh