From 7386f3efc13bd123030f5e5776aae40244366723 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 13 Dec 2021 20:11:46 +0800 Subject: [PATCH 1/5] Add CI for dotnet 6 --- .github/workflows/dotnet-build.yml | 6 +++ .github/workflows/nuget-master-publish.yml | 40 ------------------- .github/workflows/nuget-tag-publish.yml | 4 ++ ...tnetCampus.LargeAddressAware.Sample.csproj | 1 + 4 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/nuget-master-publish.yml diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index d1794a4..35fec4d 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -7,9 +7,15 @@ jobs: runs-on: windows-latest + + steps: - uses: actions/checkout@v1 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - name: Build with dotnet run: dotnet build --configuration Release diff --git a/.github/workflows/nuget-master-publish.yml b/.github/workflows/nuget-master-publish.yml deleted file mode 100644 index 9b5e85c..0000000 --- a/.github/workflows/nuget-master-publish.yml +++ /dev/null @@ -1,40 +0,0 @@ -# 去掉注释可以合并 master 分支自动打包 -# 为什么不期望推送 master 自动打包?原因是打出来的 CBB 没有 Tag 不利于回滚找到代码 - -# name: publish nuget - -# on: -# push: -# branches: -# - master - -# jobs: -# build: - -# runs-on: windows-latest - -# steps: -# - uses: actions/checkout@v1 - -# - name: Setup .NET Core -# uses: actions/setup-dotnet@v1 -# with: -# dotnet-version: 3.1.300 - -# - name: Build with dotnet -# run: | -# dotnet build --configuration Release -# dotnet pack --configuration Release --no-build - -# - name: Install Nuget -# uses: nuget/setup-nuget@v1 -# with: -# nuget-version: '5.x' - -# - name: Add private GitHub registry to NuGet -# run: | -# nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }} -# - name: Push generated package to GitHub registry -# run: | -# nuget push .\bin\Release\*.nupkg -Source github -SkipDuplicate -# nuget push .\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }} diff --git a/.github/workflows/nuget-tag-publish.yml b/.github/workflows/nuget-tag-publish.yml index 2a0cc6f..73fbf96 100644 --- a/.github/workflows/nuget-tag-publish.yml +++ b/.github/workflows/nuget-tag-publish.yml @@ -12,6 +12,10 @@ jobs: steps: - uses: actions/checkout@v1 + + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' - name: Install dotnet tool run: dotnet tool install -g dotnetCampus.TagToVersion diff --git a/samples/dotnetCampus.LargeAddressAware.Sample/dotnetCampus.LargeAddressAware.Sample.csproj b/samples/dotnetCampus.LargeAddressAware.Sample/dotnetCampus.LargeAddressAware.Sample.csproj index 7149ec5..1dd6da4 100644 --- a/samples/dotnetCampus.LargeAddressAware.Sample/dotnetCampus.LargeAddressAware.Sample.csproj +++ b/samples/dotnetCampus.LargeAddressAware.Sample/dotnetCampus.LargeAddressAware.Sample.csproj @@ -6,6 +6,7 @@ Exe net5.0;net48 x86 + false From b089ee198d089cb7be699dd6c5960dd2152e3ae7 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 13 Dec 2021 20:13:06 +0800 Subject: [PATCH 2/5] Add code format --- .github/workflows/dotnet-format.yml | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/dotnet-format.yml diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml new file mode 100644 index 0000000..9a3f13a --- /dev/null +++ b/.github/workflows/dotnet-format.yml @@ -0,0 +1,52 @@ +name: Code format check + +on: + push: + branches: + - master +jobs: + dotnet-format: + runs-on: windows-latest + steps: + + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + # 代码文件编码规范机器人,详细请看 [dotnet 在 GitHub 的 Action 上部署自动代码编码规范机器人](https://blog.lindexi.com/post/dotnet-%E5%9C%A8-GitHub-%E7%9A%84-Action-%E4%B8%8A%E9%83%A8%E7%BD%B2%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%9C%BA%E5%99%A8%E4%BA%BA.html) + - name: Install dotnetCampus.EncodingNormalior + run: dotnet tool update -g dotnetCampus.EncodingNormalior + + - name: Fix encoding + run: EncodingNormalior -f . --TryFix true + + # 代码格式化机器人,详细请看 [dotnet 基于 dotnet format 的 GitHub Action 自动代码格式化机器人](https://blog.lindexi.com/post/dotnet-%E5%9F%BA%E4%BA%8E-dotnet-format-%E7%9A%84-GitHub-Action-%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%9C%BA%E5%99%A8%E4%BA%BA.html ) + - name: Install dotnet-format + run: dotnet tool install -g dotnet-format + + - name: Run dotnet format + run: dotnet format + + - name: Commit files + # 下面将使用机器人的账号,你可以替换为你自己的账号 + run: | + git config --local user.name "github-actions-dotnet-formatter[bot]" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -a -m 'Automated dotnet-format update' + continue-on-error: true + + - name: Create Pull Request + # if: steps.format.outputs.has-changes == 'true' # 如果有格式化,才继续 + uses: peter-evans/create-pull-request@v3 + with: + title: '[Bot] Automated PR to fix formatting errors' + body: | + Automated PR to fix formatting errors + committer: GitHub + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + # 以下是给定代码审查者,需要设置仓库有权限的开发者 + assignees: lindexi,walterlv + reviewers: lindexi,walterlv + # 对应的上传分支 + branch: t/bot/fix-codeformatting \ No newline at end of file From 11f161409b16fe67c5fcfa03d322f530c6abe555 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 13 Dec 2021 20:13:54 +0800 Subject: [PATCH 3/5] Revert "Remove comment." This reverts commit d0ff8e9ef9d916eb7ec8a7c7ee254da78a5990f3. --- Directory.Build.props | 1 + src/dotnetCampus.LargeAddressAware/Program.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index d0ee5fc..0c36eed 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ $(MSBuildThisFileDirectory)bin\$(Configuration) dotnet campus(.NET 职业技术学院) + dotnet-campus https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware diff --git a/src/dotnetCampus.LargeAddressAware/Program.cs b/src/dotnetCampus.LargeAddressAware/Program.cs index a782441..8edde00 100644 --- a/src/dotnetCampus.LargeAddressAware/Program.cs +++ b/src/dotnetCampus.LargeAddressAware/Program.cs @@ -4,6 +4,7 @@ internal static class Program { private static void Main() { + } } } From 6d0e26cc7c19fef0d4d5ccc406d86d92b705cb8b Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 13 Dec 2021 20:14:00 +0800 Subject: [PATCH 4/5] Revert "Remove C# 10 feature codes." This reverts commit f7ae6d2dd1458ba211df81f5fe0ef06a72c37def. --- .../dotnetCampus.LargeAddressAware.Sample/Program.cs | 11 +++++------ src/dotnetCampus.LargeAddressAware/Program.cs | 10 ++++------ .../Properties/Global.cs | 3 +++ 3 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 src/dotnetCampus.LargeAddressAware/Properties/Global.cs diff --git a/samples/dotnetCampus.LargeAddressAware.Sample/Program.cs b/samples/dotnetCampus.LargeAddressAware.Sample/Program.cs index 4b4c1de..9768d38 100644 --- a/samples/dotnetCampus.LargeAddressAware.Sample/Program.cs +++ b/samples/dotnetCampus.LargeAddressAware.Sample/Program.cs @@ -1,12 +1,11 @@ using System; -namespace dotnetCampus.LargeAddressAware.Sample +namespace dotnetCampus.LargeAddressAware.Sample; + +internal class Program { - internal class Program + static void Main(string[] args) { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } + Console.WriteLine("Hello World!"); } } diff --git a/src/dotnetCampus.LargeAddressAware/Program.cs b/src/dotnetCampus.LargeAddressAware/Program.cs index 8edde00..c23ba21 100644 --- a/src/dotnetCampus.LargeAddressAware/Program.cs +++ b/src/dotnetCampus.LargeAddressAware/Program.cs @@ -1,10 +1,8 @@ -namespace dotnetCampus.LargeAddressAware +namespace dotnetCampus.LargeAddressAware; + +internal static class Program { - internal static class Program + private static void Main() { - private static void Main() - { - - } } } diff --git a/src/dotnetCampus.LargeAddressAware/Properties/Global.cs b/src/dotnetCampus.LargeAddressAware/Properties/Global.cs new file mode 100644 index 0000000..fe77202 --- /dev/null +++ b/src/dotnetCampus.LargeAddressAware/Properties/Global.cs @@ -0,0 +1,3 @@ +global using System; +global using System.Collections.Generic; +global using System.Text; From c9d1b0e792c9882ff08117baa48cc36715931084 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 13 Dec 2021 20:15:26 +0800 Subject: [PATCH 5/5] Remove comment --- Directory.Build.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0c36eed..d0ee5fc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,6 @@ $(MSBuildThisFileDirectory)bin\$(Configuration) dotnet campus(.NET 职业技术学院) - dotnet-campus https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware