Publish #23
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: Publish | |
on: | |
workflow_dispatch: | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
GITHUB_ACTIONS: true | |
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 Core | |
uses: actions/setup-dotnet@v2 | |
with: | |
global-json-file: global.json | |
- name: Tool Restore | |
run: dotnet tool restore | |
- name: Test | |
run: dotnet nuke test | |
- name: Build and Pack NuGet package | |
run: dotnet pack src/ --configuration Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' --output ./Package | |
- name: Upload lib NuGet package artifact to GitHub | |
uses: actions/upload-artifact@v2 | |
with: | |
name: libPackage | |
path: ./Package | |
release: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' && needs.build.outputs.CommitsSinceVersionSource > 0 #Only release if there has been a commit/version change | |
needs: build | |
steps: | |
- name: Download lib nuget package artifact | |
uses: actions/download-artifact@v1.0.0 | |
with: | |
name: libPackage | |
- name: Push package to Nuget | |
run: | | |
dotnet nuget push libPackage/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ needs.build.outputs.Version }} | |
name: Release ${{ needs.build.outputs.Version }} | |
artifacts: "libPackage/*" | |
token: ${{ secrets.GITHUB_TOKEN }} |