Skip to content

Commit

Permalink
Only publish interesting artifacts in GH build (#4635)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Dec 12, 2023
1 parent 49b5502 commit d71bd93
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
36 changes: 20 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 2 additions & 13 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 16 additions & 5 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
{
Expand All @@ -48,14 +48,25 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC
var newSteps = new List<GitHubActionsStep>(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;
}
Expand Down
4 changes: 3 additions & 1 deletion build/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public partial class Build
Target Pack => _ => _
.DependsOn(Compile)
.After(Test)
.Produces(ArtifactsDirectory / "*.*")
.Executes(() =>
{
if (Configuration != Configuration.Release)
Expand Down Expand Up @@ -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);
});
}

0 comments on commit d71bd93

Please sign in to comment.