Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Aug 22, 2024
2 parents 1dbf608 + 3f769da commit 301a328
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,12 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
# https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"

# https://github.com/joseftw/jos.enumeration/blob/main/.github/workflows/verify.yml
# https://github.com/dotnet/Nerdbank.GitVersioning
- uses: dotnet/[email protected]
id: nbgv


- name: Cache NuGet Packages
uses: actions/cache@v3
with:
Expand All @@ -40,9 +32,9 @@ jobs:
- name: Restore dependencies
run: dotnet restore Vertical.Slice.Template.sln

- name: Build Version ${{ steps.nbgv.outputs.nugetpackageversion }}
- name: Build Version
run: dotnet build Vertical.Slice.Template.sln -c Release --no-restore

- name: Test Version ${{ steps.nbgv.outputs.nugetpackageversion }}
- name: Test Version
run: |
dotnet test Vertical.Slice.Template.sln -c Release --no-restore --no-build
25 changes: 12 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
name: Publish-Nuget

on:
# push:
# tags:
# - "*"
push:
branches:
- "main"

tags:
- "*"
env:
FEED_SOURCE: https://api.nuget.org/v3/index.json
FEED_API_KEY: ${{ secrets.FEED_API_KEY }}
Expand All @@ -19,9 +15,8 @@ env:
jobs:

# https://www.meziantou.net/publishing-a-nuget-package-following-best-practices-using-github.htm
create_nuget:
create-nuget:
if: ${{ contains(fromJson('["main"]'), github.ref_name) || github.event_name == 'release' }}
needs: build

runs-on: ubuntu-latest

Expand Down Expand Up @@ -49,11 +44,11 @@ jobs:
- name: Restore dependencies
run: dotnet restore Vertical.Slice.Template.sln

- name: Build Version ${{ steps.nbgv.outputs.nugetpackageversion }}
run: dotnet build Vertical.Slice.Template.sln -c Release --no-restore /p:Version=${{ steps.nbgv.outputs.SemVer2 }}
- name: Build Version ${{ steps.nbgv.outputs.NuGetPackageVersion }}
run: dotnet build Vertical.Slice.Template.sln -c Release --no-restore /p:Version=${{ steps.nbgv.outputs.NuGetPackageVersion }}

# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack
- name: Pack NuGet Package Version ${{ steps.nbgv.outputs.nugetpackageversion }}
- name: Pack NuGet Package Version ${{ steps.nbgv.outputs.NuGetPackageVersion }}
run: dotnet pack vertical-slice-template.csproj -c Release -o ${{ env.NuGetDirectory }}

# Publish the NuGet package as an artifact, so they can be used in the following jobs
Expand All @@ -71,8 +66,12 @@ jobs:
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
# You can update this logic if you want to manage releases differently
runs-on: ubuntu-latest
needs: [create_nuget]
needs: [create-nuget]
steps:
- uses: actions/checkout@v3
with:
# https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v3
with:
Expand All @@ -94,5 +93,5 @@ jobs:
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push
- name: Publish NuGet Package Version ${{ steps.nbgv.outputs.nugetpackageversion }}
- name: Publish NuGet Package Version ${{ steps.nbgv.outputs.NuGetPackageVersion }}
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --skip-duplicate --source ${{ env.FEED_SOURCE }} --api-key ${{ env.FEED_API_KEY }}

0 comments on commit 301a328

Please sign in to comment.