-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: Add Nuget Publish * adding publish yml
- Loading branch information
1 parent
6d8d367
commit 70a91b0
Showing
3 changed files
with
150 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Nuke.Common.CI.GitHubActions; | ||
using Rocket.Surgery.Nuke; | ||
using Rocket.Surgery.Nuke.ContinuousIntegration; | ||
using Rocket.Surgery.Nuke.DotNetCore; | ||
using Rocket.Surgery.Nuke.GithubActions; | ||
|
||
[GitHubActionsSteps("ci", GitHubActionsImage.MacOsLatest, | ||
AutoGenerate = false, | ||
On = new[] { GitHubActionsTrigger.Push }, | ||
OnPushTags = new[] { "v*" }, | ||
OnPushBranches = new[] { "master", "next", "feature/*" }, | ||
OnPullRequestBranches = new[] { "master", "next" }, | ||
InvokedTargets = new[] { nameof(Default) }, | ||
NonEntryTargets = new[] | ||
{ | ||
nameof(ICIEnvironment.CIEnvironment), | ||
nameof(ITriggerCodeCoverageReports.Trigger_Code_Coverage_Reports), | ||
nameof(ITriggerCodeCoverageReports.Generate_Code_Coverage_Report_Cobertura), | ||
nameof(IGenerateCodeCoverageBadges.Generate_Code_Coverage_Badges), | ||
nameof(IGenerateCodeCoverageReport.Generate_Code_Coverage_Report), | ||
nameof(IGenerateCodeCoverageSummary.Generate_Code_Coverage_Summary), | ||
nameof(Default) | ||
}, | ||
ExcludedTargets = new[] { nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) }, | ||
Enhancements = new[] { nameof(Middleware) } | ||
)] | ||
[PrintBuildVersion, PrintCIEnvironment, UploadLogs] | ||
public partial class Solution | ||
{ | ||
public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) | ||
{ | ||
var buildJob = configuration.Jobs.First(z => z.Name == "Build"); | ||
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single(); | ||
// For fetch all | ||
checkoutStep.FetchDepth = 0; | ||
buildJob.Steps.InsertRange(buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] { | ||
new RunStep("Fetch all history for all tags and branches") { | ||
Run = "git fetch --prune" | ||
}, | ||
new SetupDotNetStep("Use .NET Core 3.1 SDK") { | ||
DotNetVersion = "3.1.x" | ||
} | ||
}); | ||
|
||
buildJob.Steps.Add(new UsingStep("Publish Coverage") | ||
{ | ||
Uses = "codecov/codecov-action@v1", | ||
With = new Dictionary<string, string> | ||
{ | ||
["name"] = "actions-${{ matrix.os }}", | ||
} | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish logs") | ||
{ | ||
Name = "logs", | ||
Path = "artifacts/logs/", | ||
If = "always()" | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish coverage data") | ||
{ | ||
Name = "coverage", | ||
Path = "coverage/", | ||
If = "always()" | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish test data") | ||
{ | ||
Name = "test data", | ||
Path = "artifacts/test/", | ||
If = "always()" | ||
}); | ||
|
||
buildJob.Steps.Add(new UploadArtifactStep("Publish NuGet Packages") | ||
{ | ||
Name = "nuget", | ||
Path = "artifacts/nuget/", | ||
If = "always()" | ||
}); | ||
|
||
return configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Publish Nuget | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['ci'] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- uses: nuget/setup-nuget@v1 | ||
with: | ||
nuget-version: '5.x' | ||
|
||
- name: Download artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
if: github.event.workflow_run.conclusion == 'success' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
workflow: ci.yml | ||
run_id: ${{ github.event.id }} | ||
name: nuget | ||
|
||
# - uses: actions/download-artifact@v2 | ||
# with: | ||
# name: nuget | ||
|
||
- name: nuget.org | ||
# continue-on-error: true | ||
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && startsWith(github.event.workflow_run.head_branch, 'v') # this is the best approximation for a tag | ||
env: | ||
ApiKey: ${{ secrets.RSG_NUGET_API_KEY }} | ||
shell: pwsh | ||
run: | | ||
dotnet nuget push **/*.nupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey | ||
dotnet nuget push **/*.snupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey | ||
- name: dev.azure.com | ||
# continue-on-error: true | ||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | ||
env: | ||
ApiKey: ${{ secrets.RSG_AZURE_DEVOPS }} | ||
shell: pwsh | ||
run: | | ||
dotnet nuget add source https://rocketsurgeonsguild.pkgs.visualstudio.com/Libraries/_packaging/Packages/nuget/v3/index.json --store-password-in-clear-text --name LibrariesPackages --username azuredevops --password $ENV:ApiKey | ||
dotnet nuget push **/*.nupkg --skip-duplicate --api-key azuredevops --source LibrariesPackages | ||
- name: preview.dev.azure.com | ||
# continue-on-error: true | ||
if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' | ||
env: | ||
ApiKey: ${{ secrets.RSG_AZURE_DEVOPS }} | ||
shell: pwsh | ||
run: | | ||
dotnet nuget add source https://rocketsurgeonsguild.pkgs.visualstudio.com/Libraries/_packaging/Preview/nuget/v3/index.json --store-password-in-clear-text --name LibrariesPreview --username azuredevops --password $ENV:ApiKey | ||
dotnet nuget push **/*.nupkg --skip-duplicate --api-key azuredevops --source LibrariesPreview |