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
name: Action to build and publish the project as a nuget package to github package registry | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
Version: ${{ steps.gitversion.outputs.SemVer }} | |
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.9.7 | |
with: | |
versionSpec: 5.x | |
- name: Determine Version | |
uses: gittools/actions/gitversion/execute@v0.9.7 | |
id: gitversion | |
- name: Display GitVersion outputs | |
run: | | |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}" | |
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 6.0.x | |
- name: Build and Pack NuGet package | |
run: dotnet pack BaseNet.Data.SDK/BaseNet.Data.SDK.csproj -p:Version='${{ steps.gitversion.outputs.SemVer }}' -c Release | |
- name: Upload NuGet package to GitHub | |
uses: actions/upload-artifact@v2 | |
with: | |
name: nugetPackage | |
path: BaseNet.Data.SDK/bin/Release/ | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Download nuget package artifact | |
uses: actions/download-artifact@v1.0.0 | |
with: | |
name: nugetPackage | |
- name: Prep packages | |
run: dotnet nuget add source --username br3nds0n --password ${{ secrets.NUGET_PACKAGE_TOKEN }} --store-password-in-clear-text --name basenet-data "https://nuget.pkg.github.com/br3nds0n/index.json" | |
- name: Push package to GitHub packages | |
if: needs.build.outputs.CommitsSinceVersionSource > 0 | |
run: dotnet nuget push nugetPackage/*.nupkg --api-key ${{ secrets.NUGET_PACKAGE_TOKEN }} --source "basenet-data" | |
- name: Create Release | |
if: 1 == 0 | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.NUGET_PACKAGE_TOKEN }} | |
with: | |
tag_name: ${{ needs.build.outputs.Version }} | |
release_name: Release ${{ needs.build.outputs.Version }} | |
- name: Create Release | |
if: needs.build.outputs.CommitsSinceVersionSource > 0 | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ needs.build.outputs.Version }} | |
name: Release ${{ needs.build.outputs.Version }} | |
artifacts: "nugetPackage/*" | |
token: ${{ secrets.NUGET_PACKAGE_TOKEN }} |