diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6a6a7b4ca..570747496 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,6 +21,7 @@ on: branches: - main - master + - 'release*' jobs: windows-latest: @@ -29,37 +30,23 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@v3 - - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 - with: - path: | - .nuke/temp - ~/.nuget/packages - key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} - name: 'Run: Clean, Test, Pack' run: ./build.cmd Clean Test Pack - - name: 'Publish: artifacts' + - name: 'Publish: publish' uses: actions/upload-artifact@v3 with: - name: artifacts - path: artifacts + name: publish + path: publish ubuntu-latest: name: ubuntu-latest runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v3 - - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 - with: - path: | - .nuke/temp - ~/.nuget/packages - key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} - name: 'Run: Clean, Test, Pack' run: ./build.cmd Clean Test Pack - - name: 'Publish: artifacts' + - name: 'Publish: publish' uses: actions/upload-artifact@v3 with: - name: artifacts - path: artifacts + name: publish + path: publish diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 197eaf8df..588cac3ac 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -25,37 +25,23 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@v3 - - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 - with: - path: | - .nuke/temp - ~/.nuget/packages - key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} - name: 'Run: Clean, Test, Pack' run: ./build.cmd Clean Test Pack - - name: 'Publish: artifacts' + - name: 'Publish: publish' uses: actions/upload-artifact@v3 with: - name: artifacts - path: artifacts + name: publish + path: publish ubuntu-latest: name: ubuntu-latest runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v3 - - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 - with: - path: | - .nuke/temp - ~/.nuget/packages - key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} - name: 'Run: Clean, Test, Pack' run: ./build.cmd Clean Test Pack - - name: 'Publish: artifacts' + - name: 'Publish: publish' uses: actions/upload-artifact@v3 with: - name: artifacts - path: artifacts + name: publish + path: publish diff --git a/build/Build.GitHubAction.cs b/build/Build.GitHubAction.cs index 46e494e73..de708aaf6 100644 --- a/build/Build.GitHubAction.cs +++ b/build/Build.GitHubAction.cs @@ -3,16 +3,18 @@ [GitHubActions("CI", GitHubActionsImage.WindowsLatest, GitHubActionsImage.UbuntuLatest, - OnPushBranches = new[] { "main", "master" }, + OnPushBranches = new[] { "main", "master", "release*" }, InvokedTargets = new[] { nameof(Clean), nameof(Test), nameof(Pack) }, - TimeoutMinutes = 20 + TimeoutMinutes = 20, + CacheKeyFiles = new string[0] )] [GitHubActions("PR", GitHubActionsImage.WindowsLatest, GitHubActionsImage.UbuntuLatest, On = new [] { GitHubActionsTrigger.PullRequest }, InvokedTargets = new[] { nameof(Clean), nameof(Test), nameof(Pack) }, - TimeoutMinutes = 20 + TimeoutMinutes = 20, + CacheKeyFiles = new string[0] )] partial class Build { diff --git a/build/Build.cs b/build/Build.cs index 586c415d8..f10232190 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,11 +1,15 @@ +using System; +using System.Linq; using System.Runtime.InteropServices; using Nuke.Common; using Nuke.Common.CI.GitHubActions; +using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Nuke.Common.Utilities.Collections; + using static Nuke.Common.Tools.DotNet.DotNetTasks; partial class Build : NukeBuild @@ -22,10 +26,26 @@ partial class Build : NukeBuild readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; [Solution] Solution Solution; + [GitRepository] readonly GitRepository GitRepository; static AbsolutePath SourceDirectory => RootDirectory / "src"; - static AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; + static AbsolutePath ArtifactsDirectory => RootDirectory / "publish"; + + string TagVersion => GitRepository.Tags.SingleOrDefault(x => x.StartsWith("v"))?[1..]; + + string BranchVersion => GitRepository.Branch?.StartsWith("release") == true + ? GitRepository.Branch[7..] + : null; + + // either from tag or branch + string PublishVersion => TagVersion ?? BranchVersion; + + bool IsPublishBuild => !string.IsNullOrWhiteSpace(PublishVersion); + + string VersionSuffix; + + static bool IsRunningOnWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); [Secret] [Parameter("GitHub API token")] @@ -33,9 +53,20 @@ partial class Build : NukeBuild protected override void OnBuildInitialized() { + VersionSuffix = !IsPublishBuild + ? $"preview-{DateTime.UtcNow:yyyyMMdd-HHmm}" + : ""; + + if (IsLocalBuild) + { + VersionSuffix = $"dev-{DateTime.UtcNow:yyyyMMdd-HHmm}"; + } + Serilog.Log.Information("BUILD SETUP"); Serilog.Log.Information("\tSolution: {Solution}", Solution); Serilog.Log.Information("\tConfiguration: {Configuration}", Configuration); + Serilog.Log.Information("\tVersion suffix: {VersionSuffix}", VersionSuffix); + Serilog.Log.Information("\tPublish version: {PublishVersion}", PublishVersion); Serilog.Log.Information("Build environment:"); Serilog.Log.Information("\tHost: {Host}", Host.GetType()); @@ -103,11 +134,11 @@ static void DeleteCompilationArtifacts() .OnlyWhenDynamic(() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Host is GitHubActions) .Executes(() => { - ProcessTasks.StartProcess("sudo", "apt install -y fonts-noto-color-emoji"); - ProcessTasks.StartProcess("mkdir", "-p /usr/local/share/fonts"); - ProcessTasks.StartProcess("cp", "/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf /usr/local/share/fonts/"); - ProcessTasks.StartProcess("chmod", "644 /usr/local/share/fonts/NotoColorEmoji.ttf"); - ProcessTasks.StartProcess("fc-cache", "-fv"); + static void StartSudoProcess(string arguments) => ProcessTasks.StartProcess("sudo", arguments).WaitForExit(); + + // replace broken font - the one coming from APT doesn't contain all expected tables + StartSudoProcess("rm /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf"); + StartSudoProcess("curl -sS -L -o /usr/share/fonts/truetype/noto/NotoColorEmoji-Regular.ttf https://fonts.gstatic.com/s/notocoloremoji/v25/Yq6P-KqIXTD0t4D9z1ESnKM3-HpFab5s79iz64w.ttf"); }); Target Pack => _ => _ @@ -120,16 +151,31 @@ static void DeleteCompilationArtifacts() var packTarget = Solution.GetProject("NPOI.Pack"); - DotNetPack(_ =>_ - .SetConfiguration(Configuration) - .SetOutputDirectory(ArtifactsDirectory) - .SetDeterministic(IsServerBuild) - .SetContinuousIntegrationBuild(IsServerBuild) - // obsolete missing XML documentation comment, XML comment on not valid language element, XML comment has badly formed XML, no matching tag in XML comment - // need to use escaped separator in order for this to work - .AddProperty("NoWarn", string.Join("%3B", new [] { 169, 612, 618, 1591, 1587, 1570, 1572, 1573, 1574 })) - .SetProperty("EnablePackageValidation", "false") - .SetProject(packTarget) - ); + DotNetPack(_ => + { + var packSettings = _ + .SetProject(packTarget) + .SetConfiguration(Configuration) + .SetOutputDirectory(ArtifactsDirectory) + .SetDeterministic(IsServerBuild) + .SetContinuousIntegrationBuild(IsServerBuild) + // obsolete missing XML documentation comment, XML comment on not valid language element, XML comment has badly formed XML, no matching tag in XML comment + // need to use escaped separator in order for this to work + .AddProperty("NoWarn", string.Join("%3B", new[] { 169, 612, 618, 1591, 1587, 1570, 1572, 1573, 1574 })) + .SetProperty("EnablePackageValidation", "false"); + + if (IsPublishBuild) + { + // force version from tag/branch + packSettings = packSettings + .SetAssemblyVersion(PublishVersion) + .SetFileVersion(PublishVersion) + .SetInformationalVersion(PublishVersion) + .SetVersionSuffix(VersionSuffix) + .SetVersionPrefix(PublishVersion); + } + + return packSettings; + }); }); } diff --git a/testcases/ooxml/XSSF/Streaming/TestAutoSizeColumnTracker.cs b/testcases/ooxml/XSSF/Streaming/TestAutoSizeColumnTracker.cs index 52d991ac6..0b74f0d29 100644 --- a/testcases/ooxml/XSSF/Streaming/TestAutoSizeColumnTracker.cs +++ b/testcases/ooxml/XSSF/Streaming/TestAutoSizeColumnTracker.cs @@ -142,6 +142,7 @@ public void isAllColumnsTracked() { } [Test] + [Platform("Win")] public void updateColumnWidths_and_getBestFitColumnWidth() { tracker.TrackAllColumns(); IRow row1 = sheet.CreateRow(0);