From d71bd9326925b60ce8df9007f87b87b723bf8e9c Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Tue, 12 Dec 2023 10:22:24 +0200 Subject: [PATCH] Only publish interesting artifacts in GH build (#4635) --- .github/workflows/build.yml | 36 ++++++++++++++++++--------------- .github/workflows/pr.yml | 15 ++------------ build/Build.CI.GitHubActions.cs | 21 ++++++++++++++----- build/Build.Pack.cs | 4 +++- 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59c0809780..08b821ccad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,27 +40,31 @@ jobs: run: | echo "Adding GNU tar to PATH" echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: | - 8.0.100 - 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', 'src/**/*.csproj', 'src/**/package.json') }} - - name: 'Run: InstallDependencies, Compile, Test, Pack, Publish' - run: ./build.cmd InstallDependencies Compile Test Pack Publish + - name: 'Run: Compile, Test, Pack, Publish' + run: ./build.cmd Compile Test Pack Publish env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }} CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }} NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - - name: 'Publish: artifacts' + - name: 'Publish: NSwag.zip' + uses: actions/upload-artifact@v3 + with: + name: NSwag.zip + path: artifacts/NSwag.zip + - name: 'Publish: NSwag.Npm.zip' + uses: actions/upload-artifact@v3 + with: + name: NSwag.Npm.zip + path: artifacts/NSwag.Npm.zip + - name: 'Publish: NSwagStudio.msi' + uses: actions/upload-artifact@v3 + with: + name: NSwagStudio.msi + path: artifacts/NSwagStudio.msi + - name: 'Publish: NuGet Packages' uses: actions/upload-artifact@v3 with: - name: artifacts - path: artifacts + name: NuGet Packages + path: artifacts/*.nupkg diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c483a50e68..36077a496c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -41,17 +41,6 @@ jobs: run: | echo "Adding GNU tar to PATH" echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: | - 8.0.100 - 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', 'src/**/*.csproj', 'src/**/package.json') }} - - name: 'Run: InstallDependencies, Compile, Test, Pack' - run: ./build.cmd InstallDependencies Compile Test Pack + - name: 'Run: Compile, Test, Pack' + run: ./build.cmd Compile Test Pack diff --git a/build/Build.CI.GitHubActions.cs b/build/Build.CI.GitHubActions.cs index b6683d010f..63df39a1e1 100644 --- a/build/Build.CI.GitHubActions.cs +++ b/build/Build.CI.GitHubActions.cs @@ -13,8 +13,8 @@ OnPullRequestIncludePaths = new[] { "**/*.*" }, OnPullRequestExcludePaths = new[] { "**/*.md" }, PublishArtifacts = false, - InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack) }, - CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" }, + InvokedTargets = new[] { nameof(Compile), nameof(Test), nameof(Pack) }, + CacheKeyFiles = new string[0], JobConcurrencyCancelInProgress = true), ] [CustomGitHubActions( @@ -27,9 +27,9 @@ OnPushIncludePaths = new[] { "**/*.*" }, OnPushExcludePaths = new[] { "**/*.md" }, PublishArtifacts = true, - InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack), nameof(Publish) }, + InvokedTargets = new[] { nameof(Compile), nameof(Test), nameof(Pack), nameof(Publish) }, ImportSecrets = new[] { "NUGET_API_KEY", "MYGET_API_KEY", "CHOCO_API_KEY", "NPM_AUTH_TOKEN" }, - CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" }) + CacheKeyFiles = new string[0]) ] public partial class Build { @@ -48,14 +48,25 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC var newSteps = new List(job.Steps); // only need to list the ones that are missing from default image + /* newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[] { "8.0.100" })); - + */ + newSteps.Insert(0, new GitHubActionsUseGnuTarStep()); newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep()); + // add artifacts manually as they would otherwise by hard to configure via attributes + if (PublishArtifacts) + { + newSteps.Add(new GitHubActionsArtifactStep { Name = "NSwag.zip", Path = "artifacts/NSwag.zip" }); + newSteps.Add(new GitHubActionsArtifactStep { Name = "NSwag.Npm.zip", Path = "artifacts/NSwag.Npm.zip" }); + newSteps.Add(new GitHubActionsArtifactStep { Name = "NSwagStudio.msi", Path = "artifacts/NSwagStudio.msi" }); + newSteps.Add(new GitHubActionsArtifactStep { Name = "NuGet Packages", Path = "artifacts/*.nupkg" }); + } + job.Steps = newSteps.ToArray(); return job; } diff --git a/build/Build.Pack.cs b/build/Build.Pack.cs index d58f4d3b73..46e525f04b 100644 --- a/build/Build.Pack.cs +++ b/build/Build.Pack.cs @@ -23,7 +23,6 @@ public partial class Build Target Pack => _ => _ .DependsOn(Compile) .After(Test) - .Produces(ArtifactsDirectory / "*.*") .Executes(() => { if (Configuration != Configuration.Release) @@ -127,6 +126,9 @@ public partial class Build // ZIP directories ZipFile.CreateFromDirectory(NSwagNpmBinaries, ArtifactsDirectory / "NSwag.Npm.zip"); ZipFile.CreateFromDirectory(NSwagStudioBinaries, ArtifactsDirectory / "NSwag.zip"); + + // NSwagStudio.msi + CopyFileToDirectory(ArtifactsDirectory / "bin" / "NSwagStudio.Installer" / Configuration / "NSwagStudio.msi", ArtifactsDirectory); }); }