Skip to content

Merge pull request #13 from wisedev-code/feat/infer-command-chat-and-… #7

Merge pull request #13 from wisedev-code/feat/infer-command-chat-and-…

Merge pull request #13 from wisedev-code/feat/infer-command-chat-and-… #7

Workflow file for this run

name: Build, Test, and Publish NuGet Package
on:
push:
branches:
- main
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x' # Change to your project’s .NET version
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack NuGet package
run: dotnet pack --configuration Release --output ./artifacts
- name: Push package to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push "./artifacts/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "$NUGET_API_KEY" --skip-duplicate
- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create a tag using today's date
TAG_NAME="v$(date +'%Y.%m.%d')"
# Get the NuGet package file name from the artifacts folder and remove its extension for the release title
NUPKG_FILE=$(basename $(find ./artifacts -name "*.nupkg" | head -n1))
RELEASE_NAME="${NUPKG_FILE%.*}"
# Get the newest markdown file from the Releases folder and read its content as release notes
NEWEST_NOTES=$(ls -t Releases/*.md | head -n1)
RELEASE_NOTES=$(cat "$NEWEST_NOTES")
# Create the GitHub release using the tag, NuGet package and release notes
gh release create "$TAG_NAME" ./artifacts/*.nupkg --title "$RELEASE_NAME" --notes "$RELEASE_NOTES"
shell: bash