Skip to content

fix test

fix test #34

name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ created ]
env:
DOTNET_VERSION: 5.0.100
DOTNET_3_VERSION: 3.1.301
AZURE_FUNCTIONAPP_NAME: 'LuasAPIFunction'
AZURE_FUNCTIONAPP_PACKAGE_PATH: './LuasAPI.AzureFunction'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_3_VERSION }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
pack:
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup .NET Core 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_3_VERSION }}
- name: Dotnet Pack Nuget
run: dotnet pack --output ./nuget-artifact --configuration Release -p:Version=${{ github.event.release.tag_name }}
- uses: actions/upload-artifact@v1
with:
name: nuget-artifact
path: ./nuget-artifact
- name: Dotnet Publish Function
run: dotnet publish ./LuasAPI.AzureFunction/LuasAPI.AzureFunction.csproj --configuration Release --output ./function-artifact
- uses: actions/upload-artifact@v1
with:
name: function-artifact
path: ./function-artifact
publish-to-nuget:
runs-on: ubuntu-latest
needs: pack
if: github.event_name == 'release' && !github.event.release.draft
steps:
- name: Setup .NET Core 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- uses: actions/download-artifact@v1
with:
name: nuget-artifact
path: ./nuget-artifact
- name: Upload Asset to Release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: nuget-artifact/LuasAPI.NET.${{ github.event.release.tag_name }}.nupkg
asset_name: nuget-artifact/LuasAPI.NET.${{ github.event.release.tag_name }}.nupkg
asset_content_type: application/zip
- name: Publish packages
run: dotnet nuget push ./nuget-artifact/**.nupkg --source nuget.org --api-key ${{secrets.NUGET_API_KEY}}
deploy-azure-function:
runs-on: ubuntu-latest
needs: pack
if: github.event_name == 'release' && !github.event.release.prerelease && !github.event.release.draft
steps:
- uses: actions/download-artifact@v1
with:
name: function-artifact
path: ./function-artifact
- name: 'Deploy LuasAPI.AzureFunction Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: './function-artifact'
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}