Publish #17
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 }} | |
PreReleaseTag: ${{ steps.gitversion.outputs.PreReleaseTag }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 5.x | |
- name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
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@v3 | |
with: | |
global-json-file: global.json | |
- name: Test | |
run: dotnet test | |
- name: Build and Pack NuGet package | |
run: | | |
dotnet pack FSharp.MinimalApi/ --configuration Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' --output ./Package | |
dotnet pack FSharp.MinimalApi.Swagger/ --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 | |
permissions: | |
contents: write | |
steps: | |
- name: Download lib nuget package artifact | |
uses: actions/[email protected] | |
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 }} |