Skip to content

updated img reference in README.md #21

updated img reference in README.md

updated img reference in README.md #21

name: Build, Test, and Publish NuGet Package
on:
push:
branches:
- main
tags:
- 'v*.*.*' # Ensure that NuGet publishing is triggered on version tags like v1.0.0
permissions:
contents: write
packages: write
jobs:
build-test-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Copy README.md to the project folder
run: cp README.md src/Solcast/README.md
- name: Set API Key Environment Variable
run: echo "SOLCAST_API_KEY=${{ secrets.SOLCAST_API_KEY }}" >> $GITHUB_ENV
- name: Restore dependencies
run: dotnet restore
- name: Run tests
run: dotnet test
- name: Extract version from Git tag
if: startsWith(github.ref, 'refs/tags/') # Ensure this runs only for tags
run: |
CLEAN_VERSION="${GITHUB_REF##*/}" # Remove 'refs/tags/'
CLEAN_VERSION="${CLEAN_VERSION#v}" # Remove leading 'v'
echo "CLEAN_VERSION=$CLEAN_VERSION" >> $GITHUB_ENV # Set it as env variable
- name: Pack NuGet Package with version from tag
if: startsWith(github.ref, 'refs/tags/') # Only package on tag creation
run: dotnet pack src/Solcast/Solcast.csproj --configuration Release --output ./nupkg /p:PackageVersion=${{ env.CLEAN_VERSION }}
- name: Publish NuGet Package to GitHub Packages
if: startsWith(github.ref, 'refs/tags/') # Only publish on tag creation
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: dotnet nuget push ./nupkg/*.nupkg --source "https://nuget.pkg.github.com/solcast/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
- name: Publish NuGet Package to NuGet.org
if: startsWith(github.ref, 'refs/tags/')
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json