Skip to content

Update .NET version #38

Update .NET version

Update .NET version #38

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET Publish Nuget Packages
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
#push:
# branches: [ "main" ]
pull_request:
types: [closed]
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
# Path to solution
SOLUTION: 'src/MAOToolkit.sln'
# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable .NET welcome and telemetry messages are displayed on the first run
DOTNET_NOLOGO: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
# GitHub Packages Feed settings
GITHUB_FEED: https://nuget.pkg.github.com/7702244/index.json
GITHUB_PAT: ${{ secrets.WRITE_PACKAGES_TOKEN }}
# Official NuGet Feed settings
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_KEY }}
# 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
permissions:
contents: write
# Max timeout for job.
timeout-minutes: 5
# 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@v3
- name: "⚒️ Setup .NET"
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: "✅ Check .NET Version"
run: echo '.NET version:' $(dotnet --version)
- name: Restore dependencies
run: dotnet restore $SOLUTION
- name: Build
run: dotnet build $SOLUTION --configuration Release --no-restore
- name: Test
run: dotnet test $SOLUTION /p:Configuration=Release --no-restore --no-build --verbosity normal
# https://github.com/heinrichreimer/action-github-changelog-generator
- name: "✏️ Generate release changelog"
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
stripGeneratorNotice: true
- name: "🖨️ Print changelog to console"
run: cat CHANGELOG.md
- name: "📤 Upload changelog"
uses: actions/[email protected]
with:
name: "Changelog"
path: CHANGELOG.md
- name: Create the package
run: dotnet pack $SOLUTION --configuration Release --no-restore --no-build --verbosity normal
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_OUTPUT
# https://github.com/ncipollo/release-action
- name: "🚀 Create GitHub release"
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.date.outputs.date }}
name: Release ${{ github.ref }} v${{ steps.date.outputs.date }}
body: ${{ steps.outputs.changelog }}
- name: Publish the package to GitHub Feed
run: dotnet nuget push **\*.nupkg --source $GITHUB_FEED --api-key $GITHUB_PAT
- name: Publish the package to NuGet Feed
if: env.NUGET_KEY != null
run: dotnet nuget push **\*.nupkg --source $NUGET_FEED --api-key $NUGET_KEY