Skip to content

Commit

Permalink
ci: some ci change
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Aug 22, 2024
1 parent 83ca0c7 commit aac0809
Showing 1 changed file with 12 additions and 33 deletions.
45 changes: 12 additions & 33 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,19 @@ jobs:
key: vertical-template-nuget
path: ~/.nuget/packages

# https://github.com/dotnet/Nerdbank.GitVersioning/blob/81162b84f1e81864d3c79ddfc4ce9794ae065574/doc/nbgv-cli.md
- name: Install nbgv dotnet tools
run: dotnet tool install --global nbgv

- name: nbgv Version
id: nbgv-version
run: |
version_info=$(nbgv get-version -f json)
echo "$version_info"
echo "Version=$(echo $version_info | grep -Po '(?<=\"Version\":\s\").*?(?=\")')" >> $GITHUB_OUTPUT
echo "AssemblyVersion=$(echo $version_info | grep -Po '(?<=\"AssemblyVersion\":\s\").*?(?=\")')" >> $GITHUB_OUTPUT
echo "NuGetPackageVersion=$(echo $version_info | grep -Po '(?<=\"NuGetPackageVersion\":\s\").*?(?=\")')" >> $GITHUB_OUTPUT
echo "SemVer2=$(echo $version_info | grep -Po '(?<=\"SemVer2\":\s\").*?(?=\")')" >> $GITHUB_OUTPUT
- name: Use Version Outputs
run: |
echo "BuildMetadataFragment: ${{ steps.nbgv-version.outputs.Version }}"
echo "NuGetPackageVersion: ${{ steps.nbgv-version.outputs.AssemblyVersion }}"
echo "ChocolateyPackageVersion: ${{ steps.nbgv-version.outputs.NuGetPackageVersion }}"
echo "NpmPackageVersion: ${{ steps.nbgv-version.outputs.SemVer2 }}"
# 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: Restore dependencies
run: dotnet restore Vertical.Slice.Template.sln

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

# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack
- name: Pack NuGet Package Version ${{ steps.nbgv-version.outputs.NuGetPackageVersion }}
- name: Pack NuGet Package Version ${{ steps.nbgv.outputs.SemVer2 }}
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 Down Expand Up @@ -101,25 +85,20 @@ jobs:
with:
dotnet-version: "8.0.x"

# https://github.com/dotnet/Nerdbank.GitVersioning/blob/81162b84f1e81864d3c79ddfc4ce9794ae065574/doc/nbgv-cli.md
- name: Install nbgv dotnet tools
run: dotnet tool install -g nbgv

- name: nbgv Version
id: nbgv-version
run: |
$version = nbgv get-version -f json | ConvertFrom-Json
echo "version=$($version.NuGetPackageVersion)" >> "$GITHUB_OUTPUT"
# https://github.com/joseftw/jos.enumeration/blob/main/.github/workflows/verify.yml
# https://github.com/dotnet/Nerdbank.GitVersioning
- uses: dotnet/[email protected]
id: nbgv

# for publish package to github for each commit
- name: Publish NuGet Package Version ${{ steps.nbgv-version.outputs.version }} to GitHub
- name: Publish NuGet Package Version ${{ steps.nbgv.outputs.SemVer2 }} to GitHub
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --skip-duplicate
if: github.event_name == 'push' && startswith(github.ref, 'refs/heads')

# Publish all NuGet packages to NuGet.org
# 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-version.outputs.version }} to Nuget
- name: Publish NuGet Package Version ${{ steps.nbgv.outputs.SemVer2 }} to Nuget
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --skip-duplicate --source ${{ env.FEED_SOURCE }} --api-key ${{ env.FEED_API_KEY }}
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')

0 comments on commit aac0809

Please sign in to comment.