Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/build cache #619

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal class LocalConstants
"ci-ignore",
GitHubActionsImage.WindowsLatest,
GitHubActionsImage.UbuntuLatest,
AutoGenerate = false,
On = new[] { GitHubActionsTrigger.Push },
OnPushTags = new[] { "v*" },
OnPushBranches = new[] { "master", "main", "next" },
Expand All @@ -42,6 +43,7 @@ internal class LocalConstants
GitHubActionsImage.MacOsLatest,
GitHubActionsImage.WindowsLatest,
GitHubActionsImage.UbuntuLatest,
AutoGenerate = false,
On = new[] { GitHubActionsTrigger.Push },
OnPushTags = new[] { "v*" },
OnPushBranches = new[] { "master", "main", "next" },
Expand Down Expand Up @@ -101,6 +103,7 @@ RocketSurgeonGitHubActionsConfiguration configuration
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single();
// For fetch all
checkoutStep.FetchDepth = 0;
buildJob.Environment["NUGET_PACKAGES"] = "${{ github.workspace }}/.nuget/packages";
buildJob.Steps.InsertRange(
buildJob.Steps.IndexOf(checkoutStep) + 1,
new BaseGitHubActionsStep[]
Expand All @@ -109,9 +112,18 @@ RocketSurgeonGitHubActionsConfiguration configuration
{
Run = "git fetch --prune"
},
new SetupDotNetStep("Use .NET Core 2.1 SDK")
new UsingStep("NuGet Cache")
{
DotNetVersion = "2.1.x"
Uses = "actions/cache@v2",
With =
{
["path"] = "${{ github.workspace }}/.nuget/packages",
// keep in mind using central package versioning here
["key"] =
"${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
["restore-keys"] = @"|
${{ runner.os }}-nuget-"
}
},
new SetupDotNetStep("Use .NET Core 3.1 SDK")
{
Expand All @@ -120,7 +132,7 @@ RocketSurgeonGitHubActionsConfiguration configuration
new SetupDotNetStep("Use .NET Core 6.0 SDK")
{
DotNetVersion = "6.0.x"
},
}
}
);

Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ on:

jobs:
Build:
env:
NUGET_PACKAGES: '${{ github.workspace }}/.nuget/packages'
strategy:
fail-fast: false
matrix:
Expand All @@ -76,10 +78,13 @@ jobs:
- name: Fetch all history for all tags and branches
run: |
git fetch --prune
- name: 🔨 Use .NET Core 2.1 SDK
uses: actions/setup-dotnet@v1.9.0
- name: NuGet Cache
uses: actions/cache@v2
with:
dotnet-version: '2.1.x'
path: '${{ github.workspace }}/.nuget/packages'
key: "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}"
restore-keys: |
${{ runner.os }}-nuget-
- name: 🔨 Use .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1.9.0
with:
Expand Down Expand Up @@ -134,7 +139,7 @@ jobs:
Publish:
needs:
- Build
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0
secrets:
RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}'
RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}'
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
. "$(dirname "$0")/_/husky.sh"

npx lint-staged -d -r
dotnet nuke --generate-configuration GitHubActions_ci --host GitHubActions
git add .github/workflows/ci.yml
dotnet nuke --generate-configuration GitHubActions_ci-ignore --host GitHubActions
git add .github/workflows/ci-ignore.yml
Loading