Workflow file for this run
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: Build, Test and Publish Nuget Package | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
pull_request: | |
branches: | |
- "**" | |
env: | |
VERSION: 0.0.0.0-build # Default version to run simple build and test | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set Version Variable | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
TAG: ${{ github.ref_name }} | |
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore /p:Version=$VERSION | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
- name: Pack Moneta Core | |
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') | |
run: dotnet pack src/Moneta --output nupkgs --no-restore /p:PackageVersion=$VERSION | |
- name: Upload nuget packages | |
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') | |
run: dotnet nuget push nupkgs/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json |