Skip to content

Update main.yml

Update main.yml #28

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: PublishToNuget
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Restore dependencies
run: dotnet restore
- name: Build dotnet
run: dotnet build MimeBank.sln --configuration release
- name: Run Tests
run: dotnet test --configuration Release --no-build --verbosity normal --logger:"nunit;LogFilePath=test-results.xml"
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
id: test-results
if: always()
with:
files: |
./**/test-results.xml
- name: Set badge color
shell: bash
run: |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
success)
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
;;
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: Create badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Tests
status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
color: ${{ env.BADGE_COLOR }}
path: badge.svg
- name: Upload badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/detaybey/2fedd2a36dc6905b3cda91d58d1a5fc0
file: badge.svg
- name: Package nuget
run: dotnet pack MimeBank.sln --configuration release
- name: publish on version change
id: publish_nuget
uses: alirezanet/[email protected]
with:
PROJECT_FILE_PATH: MimeBank/MimeBank.csproj
PACKAGE_NAME: MimeBank
NUGET_KEY: ${{secrets.NUGET_KEY}}