chore: clean-up and prepare NuGet publish #7
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: ci | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
pull_request: | |
branches: | |
- "main" | |
env: | |
VERSION: 0.0.1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
NuGetDirectory: ${{ github.workspace}}/nuget | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Set Version Variable | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
TAG: ${{ github.ref_name }} | |
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV | |
- name: Build Aspire.Hosting.Spin | |
run: dotnet build --configuration Release /p:Version=$VERSION | |
working-directory: ./Aspire.Hosting.Spin | |
- name: Run Tests | |
run: dotnet test --logger trx --results-directory "test-results" | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dotnet-test-results | |
path: test-results | |
if: ${{ always() }} | |
- name: Install .NET Aspire Workload | |
run: dotnet workload install aspire | |
- name: Build Sample Application | |
run: dotnet build --configuration Release | |
working-directory: ./example/host | |
- name: Publish NuGet Package | |
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') | |
run: dotnet nuget push ./Aspire.Hosting.Spin/bin/Release/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json |