Skip to content

Commit 3a65c66

Browse files
author
lith
committed
auto commit 1.5
1 parent d43599e commit 3a65c66

7 files changed

Lines changed: 213 additions & 93 deletions

File tree

.github/workflows/action-main.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push tag
8+
push:
9+
tags:
10+
- '*'
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
16+
jobs:
17+
# This workflow contains a single job called "build"
18+
build:
19+
# The type of runner that the job will run on
20+
runs-on: ubuntu-latest
21+
22+
# Steps represent a sequence of tasks that will be executed as part of the job
23+
steps:
24+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25+
- uses: actions/checkout@v2
26+
27+
# Runs a set of commands using the runners shell
28+
- name: Run startup.sh
29+
run: |
30+
set -e
31+
echo start build
32+
export DOCKER_USERNAME="${{ secrets.DOCKER_USERNAME }}"
33+
export DOCKER_PASSWORD="${{ secrets.DOCKER_PASSWORD }}"
34+
export NUGET_SERVER="${{ secrets.NUGET_SERVER }}"
35+
export NUGET_KEY="${{ secrets.NUGET_KEY }}"
36+
export GIT_SSH_SECRET="${{ secrets.GIT_SSH_SECRET }}"
37+
cd ./Publish/DevOps
38+
bash startup.sh
39+
echo build succeed!
40+
41+
- name: Release-Create
42+
id: create_release
43+
uses: actions/create-release@v1
44+
if: hashFiles(env.release_assetPath)
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
with:
48+
release_name: ${{ env.release_name }}
49+
tag_name: ${{ env.release_tag }}
50+
draft: ${{ env.Release_draft }}
51+
prerelease: ${{ env.release_prerelease }}
52+
body: ${{ env.release_body }}
53+
- name: Release-Upload
54+
id: upload-release-asset
55+
uses: actions/upload-release-asset@v1
56+
if: hashFiles(env.release_assetPath)
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
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
61+
asset_path: ${{ env.release_assetPath }}
62+
asset_name: ${{ env.release_assetName }}
63+
asset_content_type: ${{ env.release_contentType }}

.github/workflows/main.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

FileZip/FileZip.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp2.1</TargetFramework>
6-
<Version>1.4</Version>
6+
<Version>1.5</Version>
77
</PropertyGroup>
88

99
<PropertyGroup>

Publish/DevOps/20.docker-build.sh

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
11
set -e
22

3-
# cd /root/docker/jenkins/workspace/filezip/svn/Publish/DevOps; bash 20.docker-build.sh
43

4+
#---------------------------------------------------------------------
5+
#(x.1)参数
6+
args_="
57
6-
#(x.1)当前路径
7-
curWorkDir=$PWD
8-
curPath=$(dirname $0)
9-
10-
cd $curPath/../..
11-
codePath=$PWD
12-
# codePath=/root/docker/jenkins/workspace/filezip/svn
13-
8+
export codePath=/root/docker/jenkins/workspace/sqler/svn
149
15-
16-
# export DOCKER_USERNAME=serset
17-
# export DOCKER_PASSWORD=xxx
18-
export name=filezip
19-
export projectPath='FileZip'
2010
2111
12+
export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
2213
14+
export name=sqler
15+
export projectPath=Sqler
2316
24-
echo "(x.2)get version"
25-
version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -o '[0-9][0-9\.]\+'`
26-
# echo $version
17+
export DOCKER_USERNAME=serset
18+
export DOCKER_PASSWORD=xxx
2719
20+
# "
2821

22+
2923

3024

31-
tag=$version
32-
echo "(x.3)发布项目 $name:$tag"
25+
#---------------------------------------------------------------------
26+
echo "(x.2)dotnet-构建并发布项目文件"
3327

3428
docker run -i --rm \
3529
--env LANG=C.UTF-8 \
3630
-v $codePath:/root/code \
3731
serset/dotnet:6.0-sdk \
3832
bash -c "
39-
cd '/root/code/$projectPath';
40-
dotnet build --configuration Release;
33+
cd '/root/code/$projectPath'
34+
dotnet build --configuration Release
4135
dotnet publish --configuration Release --output '/root/code/Publish/06.Docker/制作镜像/$name/app' "
4236

4337

4438

4539

4640

4741
#---------------------------------------------------------------------
48-
#(x.4.1)初始化构建器
42+
#(x.3.1)docker-初始化多架构构建器
4943

5044
#启用 buildx 插件
5145
export DOCKER_CLI_EXPERIMENTAL=enabled
@@ -72,12 +66,11 @@ docker buildx ls
7266

7367

7468
#---------------------------------------------------------------------
75-
#(x.4.2)构建多架构镜像( arm、arm64 和 amd64 )并推送到 Docker Hub
69+
#(x.3.2)docker-构建多架构镜像( arm、arm64 和 amd64 )并推送到 Docker Hub
7670

7771
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
7872

79-
cd $codePath/Publish/06.Docker/制作镜像/$name
80-
docker buildx build . -t $DOCKER_USERNAME/$name:$tag -t $DOCKER_USERNAME/$name --platform=linux/amd64,linux/arm64,linux/arm/v7 --push
73+
docker buildx build $codePath/Publish/06.Docker/制作镜像/$name -t $DOCKER_USERNAME/$name:$tag -t $DOCKER_USERNAME/$name --platform=linux/amd64,linux/arm64,linux/arm/v7 --push
8174

8275

8376

@@ -86,7 +79,6 @@ docker buildx build . -t $DOCKER_USERNAME/$name:$tag -t $DOCKER_USERNAME/$name -
8679

8780

8881

89-
#(x.5)
90-
cd $curWorkDir
82+
9183

9284

Original file line numberDiff line numberDiff line change
@@ -1,56 +1,58 @@
11
set -e
22

3-
# cd /root/docker/jenkins/workspace/filezip/svn/Publish/DevOps; bash 30.release-build.sh
43

4+
#---------------------------------------------------------------------
5+
#(x.1)参数
6+
args_="
57
8+
export codePath=/root/docker/jenkins/workspace/sqler/svn
69
7-
#(x.1)当前路径
8-
curWorkDir=$PWD
9-
curPath=$(dirname $0)
1010
11-
cd $curPath/../..
12-
codePath=$PWD
13-
# codePath=/root/docker/jenkins/workspace/filezip/svn
1411
12+
export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
1513
16-
# export GIT_SSH_SECRET=xxxxxx
17-
export name=filezip
14+
export name=sqler
1815
16+
export export GIT_SSH_SECRET=xxxxxx
1917
20-
echo "(x.2)get version"
21-
version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -o '[0-9][0-9\.]\+'`
22-
# echo $version
18+
# "
2319

20+
2421

2522

2623

2724
#----------------------------------------------
28-
echo "(x.2)构建最终文件夹"
29-
mkdir -p $codePath/Publish/release
25+
echo "(x.2.1)发布文件-创建文件夹及内容"
3026
mkdir -p $codePath/Publish/git
27+
mkdir -p $codePath/Publish/release
3128

3229
cp -rf $codePath/Publish/04.服务站点 $codePath/Publish/release/04.服务站点
3330
cp -rf $codePath/Publish/06.Docker $codePath/Publish/release/06.Docker
3431
cp -rf $codePath/Publish/06.Docker/制作镜像/${name}/app $codePath/Publish/release/04.服务站点/${name}
3532

36-
33+
34+
echo "(x.2.3)发布文件-压缩"
3735
docker run --rm -i \
3836
-v $codePath/Publish:/root/file \
39-
serset/filezip dotnet FileZip.dll zip -i /root/file/release -o /root/file/git/${name}${version}.zip
37+
serset/filezip dotnet FileZip.dll zip -i /root/file/release -o /root/file/git/${name}-${version}.zip
4038

4139

4240

41+
42+
43+
44+
45+
4346
#----------------------------------------------
44-
echo "(x.3)提交release文件到github"
45-
# releaseFile=$codePath/Publish/git/${name}${version}.zip
47+
echo "(x.3)github-提交release文件到release仓库"
48+
# releaseFile=$codePath/Publish/git/${name}-${version}.zip
4649

4750
#复制ssh key
48-
cd $codePath/Publish
4951
echo "${GIT_SSH_SECRET}" > $codePath/Publish/git/serset
5052
chmod 600 $codePath/Publish/git/serset
5153

5254
#推送到github
53-
docker run -i --rm -v $PWD/git:/root/git serset/git-client bash -c " \
55+
docker run -i --rm -v $codePath/Publish/git:/root/git serset/git-client bash -c " \
5456
set -e
5557
ssh-agent bash -c \"
5658
ssh-add /root/git/serset
@@ -61,15 +63,14 @@ mkdir -p /root/code
6163
cd /root/code
6264
git clone git@github.com:serset/release.git /root/code
6365
mkdir -p /root/code/file/${name}
64-
cp /root/git/${name}${version}.zip /root/code/file/${name}
65-
git add file/${name}/${name}${version}.zip
66-
git commit -m 'auto commit ${version}'
66+
cp /root/git/${name}-${version}.zip /root/code/file/${name}
67+
git add file/${name}/${name}-${version}.zip
68+
git commit -m 'auto commit ${version}'
6769
git push -u origin master \" "
6870

6971

7072

7173

72-
#(x.5)
73-
cd $curWorkDir
7474

7575

76+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
set -e
2+
3+
4+
#---------------------------------------------------------------------
5+
#(x.1)参数
6+
args_="
7+
8+
export codePath=/root/docker/jenkins/workspace/sqler/svn
9+
10+
11+
12+
export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
13+
14+
export name=sqler
15+
16+
# "
17+
18+
19+
20+
21+
22+
#---------------------------------------------------------------------
23+
#(x.2)初始化github release环境变量
24+
# releaseFile=$codePath/Publish/git/${name}-${version}.zip
25+
26+
filePath="$codePath/Publish/git/${name}-${version}.zip"
27+
#name=Vit.Library
28+
#version=2.5
29+
30+
31+
32+
fileType="${filePath##*.}"
33+
echo "release_name=${name}-${version}" >> $GITHUB_ENV
34+
echo "release_tag=${version}" >> $GITHUB_ENV
35+
36+
echo "release_draft=false" >> $GITHUB_ENV
37+
echo "release_prerelease=false" >> $GITHUB_ENV
38+
39+
echo "release_body=" >> $GITHUB_ENV
40+
41+
echo "release_assetPath=${filePath}" >> $GITHUB_ENV
42+
echo "release_assetName=${name}-${version}.${fileType}" >> $GITHUB_ENV
43+
echo "release_contentType=application/${fileType}" >> $GITHUB_ENV
44+
45+
46+
47+
48+

0 commit comments

Comments
 (0)