Skip to content

Update github actions #192

Update github actions

Update github actions #192

name: Continuous Integration
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v4
with:
submodules: true # Fetch and checkout submodules
fetch-depth: 0 # Ensure the full history is fetched, useful when dealing with submodules
- name: 📦 Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: 💉 Install dependencies
run: dotnet restore
- name: 🛠️ Build
run: dotnet build --configuration Release --no-restore
- name: ✅ Test
run: dotnet test --no-restore --verbosity normal
- name: ⬆️ Publish Test Results
uses: actions/upload-artifact@v4
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
path: '**/TestResults/*'
retention-days: 30
- name: 📦 Package NuGet
run: dotnet pack --no-build --configuration Release
- name: 📤 Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: nupkg
path: Guppi.Console/nupkg/*.nupkg
retention-days: 5
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: build
# only push nuget package for PRs merged to master
if: github.ref == 'refs/heads/main'
steps:
- name: 📥 Download Artifacts
uses: actions/download-artifact@v4
with:
name: nupkg
- name: 🔑 Authenticate to GitHub Packages
run: dotnet nuget add source --username rprouse --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/rprouse/index.json"
- name: 📤 Publish NuGet to GitHub Packages
run: dotnet nuget push "**/dotnet-guppi.*.nupkg" -k ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate --no-symbols