diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 00000000..5510a562 --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,75 @@ +on: + push: + paths-ignore: + - "**/*.md" + - "**/*.yml" + +jobs: + build_and_test: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 6.x + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Run the build script + uses: cake-build/cake-action@v2 + env: + diadoc_signing_secret: ${{ secrets.DIADOC_SIGNING_SECRET }} + github_ref_type: ${{ github.ref_type }} + with: + target: Default + arguments: | + configuration: Release + verbosity: Diagnostic + cake-version: 1.3.0 + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: packages + path: | + bin/Release/*.nupkg + bin/Release/*.zip + if-no-files-found: error + + publish: + runs-on: ubuntu-22.04 + needs: build_and_test + if: startsWith(github.event.ref, 'refs/tags/version') + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.x + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: packages + + - name: Create github release + uses: softprops/action-gh-release@v1 + with: + fail_on_unmatched_files: true + draft: false + prerelease: false + files: | + **/*.nupkg + **/*.zip + + - name: Push NuGet package + run: | + dotnet nuget push "**/*.nupkg" --source ${{ secrets.NUGET_SOURCE }} --api-key ${{ secrets.NUGET_KEY }} \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index f7162e69..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: 1.0.{build} -os: Visual Studio 2019 -assembly_info: - patch: false -platform: Any CPU -configuration: - - Debug - - Release - -environment: - diadoc_signing_secret: - secure: prJOj46LFF9HWKRH4PZ8vSS7wgSkkAFIkSCkfqWfAoPNGhUcYqplF4h4PyxEmMjb - -build_script: -- ps: .\build.ps1 -Target "AppVeyor" -Configuration $env:configuration -Verbosity Diagnostic - -test: off - -deploy: - - provider: GitHub - release: $(appveyor_repo_tag_name) - description: 'diadocsdk-csharp' - auth_token: - secure: BSnVMByuW1RN2cKD//7Y2+RRjsmhSfgBd2QK7IpyAadKDh8dIsYe4MF9bvX0SnEz # encrypted token from GitHub - artifact: diadocsdk-csharp-net35-binaries.zip;diadocsdk-csharp-net461-binaries.zip;/\.nupkg$/ - draft: false - prerelease: false - on: - branch: master # release from master branch only - configuration: Release # deploy release configuration - appveyor_repo_tag: true # deploy on tag push only - appveyor_repo_tag_name: /^versions/ - - - provider: NuGet - api_key: - secure: 17jR0u6vM/prIqYeyBSthM9p5tlt4nDSmC2XwqvHgJaRDhROMN/4r+M3ENVh9tx/ - skip_symbols: true - artifact: /\.nupkg$/ - on: - branch: master # release from master branch only - configuration: Release # deploy release configuration - appveyor_repo_tag: true # deploy on tag push only - appveyor_repo_tag_name: /^versions/ diff --git a/build.cake b/build.cake index 3079cefb..38d4bebf 100644 --- a/build.cake +++ b/build.cake @@ -1,10 +1,10 @@ #tool "nuget:?package=ILMerge&version=2.12.803" -#addin "nuget:?package=Cake.Git&version=0.21.0" +#addin "nuget:?package=Cake.Git&version=1.0.0" #tool "nuget:?package=ILRepack.MSBuild.Task&version=2.0.13" #tool "nuget:?package=protobuf-net&version=1.0.0.280" #tool "nuget:?package=secure-file&version=1.0.31" #tool "nuget:?package=Brutal.Dev.StrongNameSigner&version=2.7.1" -#addin "nuget:?package=Cake.StrongNameSigner&version=0.1.0" +#addin "nuget:?package=Cake.StrongNameSigner&version=0.2.0" using Cake.Common.Diagnostics; using Cake.Git; using System.Text.RegularExpressions; @@ -21,7 +21,6 @@ var binariesNet45Zip = buildDir.CombineWithFilePath("diadocsdk-csharp-net45-bina var binariesNet461Zip = buildDir.CombineWithFilePath("diadocsdk-csharp-net461-binaries.zip"); var binariesNetStandard2Zip = buildDir.CombineWithFilePath("diadocsdk-csharp-netstandard2.0-binaries.zip"); var needSigning = false; - var packageVersion = ""; ////////////////////////////////////////////////////////////////////// @@ -30,7 +29,7 @@ var packageVersion = ""; Setup(context => { - if (BuildSystem.IsRunningOnAppVeyor && AppVeyor.Environment.PullRequest.IsPullRequest) + if (BuildSystem.IsRunningOnGitHubActions && BuildSystem.GitHubActions.Environment.PullRequest.IsPullRequest) { needSigning = false; return; @@ -72,7 +71,7 @@ Task("GenerateVersionInfo") var tagVersion = GetVersionFromTag(); var clearVersion = ClearVersionTag(tagVersion) ?? "1.0.0"; var semanticVersionForNuget = GetSemanticVersionV1(clearVersion); - var semanticVersion = GetSemanticVersionV2(clearVersion) + dbgSuffix; + var semanticVersion = semanticVersionForNuget + dbgSuffix; var versionParts = clearVersion.Split('.'); var majorVersion = 1; @@ -271,21 +270,6 @@ Task("Nuget-Pack") NuGetPack("./nuspec/DiadocApi.nuspec", nuGetPackSettings); }); -Task("PublishArtifactsToAppVeyor") - .IsDependentOn("Nuget-Pack") - .WithCriteria(x => BuildSystem.IsRunningOnAppVeyor) - .Does(() => - { - AppVeyor.UploadArtifact(binariesNet35Zip); - AppVeyor.UploadArtifact(binariesNet45Zip); - AppVeyor.UploadArtifact(binariesNet461Zip); - AppVeyor.UploadArtifact(binariesNetStandard2Zip); - foreach (var upload in GetFiles(buildDir + "/*.nupkg")) - { - AppVeyor.UploadArtifact(upload​); - } - }); - Task("Test") .IsDependentOn("Build") .Does(() => @@ -301,9 +285,6 @@ Task("Test") // TASK TARGETS ////////////////////////////////////////////////////////////////////// -Task("Default") - .IsDependentOn("AppVeyor"); - Task("FullBuild") .IsDependentOn("GenerateVersionInfo") .IsDependentOn("Build"); @@ -313,13 +294,12 @@ Task("Rebuild") .IsDependentOn("GenerateVersionInfo") .IsDependentOn("Build"); -Task("Appveyor") +Task("Default") .IsDependentOn("PrepareBinaries") .IsDependentOn("Build") .IsDependentOn("Test") .IsDependentOn("Repack") - .IsDependentOn("Nuget-Pack") - .IsDependentOn("PublishArtifactsToAppVeyor"); + .IsDependentOn("Nuget-Pack"); ////////////////////////////////////////////////////////////////////// // EXECUTION @@ -335,12 +315,12 @@ public string GetVersionFromTag() { var lastestTag = ""; - if (BuildSystem.IsRunningOnAppVeyor) + if (BuildSystem.GitHubActions.IsRunningOnGitHubActions) { - var tag = BuildSystem.AppVeyor.Environment.Repository.Tag; - if (tag.IsTag) + var workflow = BuildSystem.GitHubActions.Environment.Workflow; + if(EnvironmentVariable("github_ref_type") == "tag") { - return tag.Name; + return workflow.Ref.Replace("refs/tags/", ""); } } @@ -361,49 +341,21 @@ public string GetVersionFromTag() public string GetSemanticVersionV1(string clearVersion) { - if (BuildSystem.IsRunningOnAppVeyor) + if (BuildSystem.GitHubActions.IsRunningOnGitHubActions) { - var tag = BuildSystem.AppVeyor.Environment.Repository.Tag; - if (tag.IsTag) + var workflow = BuildSystem.GitHubActions.Environment.Workflow; + if(EnvironmentVariable("github_ref_type") == "tag") { return clearVersion; } - - var buildNumber = BuildSystem.AppVeyor.Environment.Build.Number; + + var buildNumber = workflow.RunNumber; return $"{clearVersion}-CI{buildNumber}"; } return $"{clearVersion}-dev"; } -public string GetSemanticVersionV2(string clearVersion) -{ - if (BuildSystem.IsRunningOnAppVeyor) - { - var tag = BuildSystem.AppVeyor.Environment.Repository.Tag; - if (tag.IsTag) - { - return clearVersion; - } - - return GetAppVeyorBuildVersion(clearVersion); - } - return $"{clearVersion}-dev"; -} - -public string GetAppVeyorBuildVersion(string clearVersion) -{ - if (BuildSystem.IsRunningOnAppVeyor) - { - var buildNumber = BuildSystem.AppVeyor.Environment.Build.Number; - clearVersion += $"-CI.{buildNumber}"; - return (AppVeyor.Environment.PullRequest.IsPullRequest - ? clearVersion += $"-PR.{AppVeyor.Environment.PullRequest.Number}" - : clearVersion += "-" + AppVeyor.Environment.Repository.Branch); - } - return clearVersion; -} - public static string ClearVersionTag(string lastestTag) { if (string.IsNullOrEmpty(lastestTag)) @@ -418,4 +370,4 @@ public static string ClearVersionTag(string lastestTag) return match.Success ? match.Value : lastestTag; -} +} \ No newline at end of file diff --git a/tests/DiadocApi-Tests.csproj b/tests/DiadocApi-Tests.csproj index 966f632a..6efc8ae4 100644 --- a/tests/DiadocApi-Tests.csproj +++ b/tests/DiadocApi-Tests.csproj @@ -2,7 +2,7 @@ Diadoc.Api.Tests DiadocApi.Tests - net35;net40;net45;net461;net472;net5.0 + net35;net40;net45;net461;net472;net6.0 false $(SolutionDir)\bin\$(Configuration)\$(AssemblyName)\