Update tests. #10
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
# build.yml v1.4 | |
# 1.4 - Avoid set-env. | |
# 1.3 - Include tag workflow in this file. | |
# 1.2 - Define DOTNET_SKIP_FIRST_TIME_EXPERIENCE/NUGET_XMLDOC_MODE. | |
# 1.1 - Use actions/cache@v2. | |
# 1.0 - Initial release. | |
name: Build | |
on: | |
- push | |
env: | |
CI: 'true' | |
DOTNET_CLI_TELEMETRY_OPTOUT: 'true' | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true' | |
NUGET_XMLDOC_MODE: 'skip' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dump context | |
env: | |
CONTEXT: ${{ toJson(github) }} | |
run: | | |
echo "Context: $Env:CONTEXT" | |
- name: Determine cache fallbacks | |
if: github.event_name != 'push' | |
id: cache_fallbacks | |
run: | | |
echo "::set-output name=nuget::nuget-" | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Cache nuget | |
uses: actions/cache@v2 | |
with: | |
path: ~/.nuget/packages | |
key: nuget-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/*.props') }} | |
restore-keys: ${{ steps.cache_fallbacks.outputs.nuget }} | |
- name: Get existing tag | |
id: existingtag | |
uses: WyriHaximus/[email protected] | |
continue-on-error: true | |
- name: Get current version | |
run: | | |
dotnet tool install --global Nito.ProjProps | |
echo "NEWTAG=v$(projprops --name version --output-format SingleValueOnly --project src --project-search)" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
dotnet build --configuration Release | |
dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" | |
dotnet pack --configuration Release --no-build | |
- name: Upload package artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: nuget-packages | |
path: | | |
**/*.nupkg | |
**/*.snupkg | |
- name: Publish code coverage | |
uses: codecov/codecov-action@v1 | |
- name: Publish packages | |
if: env.NEWTAG != steps.existingtag.outputs.tag | |
run: | | |
dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} | |
- name: Create tag | |
if: env.NEWTAG != steps.existingtag.outputs.tag | |
run: | | |
git tag ${{ env.NEWTAG }} | |
git push --tags |