Skip to content

Commit

Permalink
Added actions/cache@v3 baed on nuget lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Romanowski committed Sep 8, 2023
1 parent 10adf95 commit f998f0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ env:
SLN: OpenApiLINQPadDriver.sln
CONFIGURATION: Release
RETENTION_DAYS: 1
NUGET_DIRECTORY: ${{ github.workspace }}/nuget
NUGET_OUTPUT_DIRECTORY: ${{ github.workspace }}/nuget
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

jobs:
build:
Expand All @@ -30,7 +31,17 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3

- name : Restore Cache
id: cache
uses: actions/cache@v3
with:
path: ${{ env.NUGET_PACKAGES }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: dotnet restore ${{ env.SLN }}

- name: ${{ env.SLN }} ${{ env.CONFIGURATION }} Build
Expand All @@ -53,13 +64,13 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{ env.NUGET_DIRECTORY }}
path: ${{ env.NUGET_OUTPUT_DIRECTORY }}

- name: Setup .NET Core
uses: actions/setup-dotnet@v3

- name: Publish NuGet package
run: |
foreach($file in (Get-ChildItem "${{ env.NUGET_DIRECTORY }}" -Recurse -Include ${{ env.PACKAGE_NAME }}.nupkg)) {
foreach($file in (Get-ChildItem "${{ env.NUGET_OUTPUT_DIRECTORY }}" -Recurse -Include ${{ env.PACKAGE_NAME }}.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}
1 change: 1 addition & 0 deletions OpenApiLINQPadDriver/OpenApiLINQPadDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit f998f0e

Please sign in to comment.