diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml index e58a112..3f77da9 100644 --- a/.github/workflows/build-test-package.yml +++ b/.github/workflows/build-test-package.yml @@ -12,49 +12,107 @@ permissions: packages: write jobs: - build-test-publish: + + build: + 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: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v3 + with: + name: build_artifacts + path: | + **/bin/Release/** + + test: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' + + - name: Download Build Artifacts + uses: actions/download-artifact@v3 + with: + name: build_artifacts + + - name: Set API Key Environment Variable + run: echo "SOLCAST_API_KEY=${{ secrets.SOLCAST_API_KEY }}" >> $GITHUB_ENV + + - name: Run tests + run: dotnet test --no-build --configuration Release + + package: + if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' + + - name: Extract version from Git tag + 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: Copy README.md to the project folder + run: cp README.md src/Solcast/README.md + - name: Restore dependencies + run: dotnet restore + + - name: Pack NuGet Package with version from tag + run: dotnet pack src/Solcast/Solcast.csproj --configuration Release --output ./nupkg /p:PackageVersion=${{ env.CLEAN_VERSION }} + + - name: Upload Package Artifact + uses: actions/upload-artifact@v3 + with: + name: nuget_package + path: ./nupkg/*.nupkg + + publish: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: package 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 + - name: Download Package Artifact + uses: actions/download-artifact@v3 + with: + name: nuget_package + + - name: Publish NuGet Package to GitHub Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: dotnet nuget push ./*.nupkg --source "https://nuget.pkg.github.com/solcast/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Publish NuGet Package to NuGet.org + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: dotnet nuget push ./*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index c3886b2..ca96f0d 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,9 +1,8 @@ -# Sample workflow for building and deploying a Jekyll site to GitHub Pages name: Deploy Docs on: workflow_run: - workflows: ["Build, Test, and Publish NuGet Package"] # Name of the build workflow + workflows: ["Build, Test, and Publish NuGet Package"] types: - completed @@ -24,6 +23,7 @@ concurrency: jobs: deploy_docs: + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest steps: - name: Checkout Repository diff --git a/README.md b/README.md index 9b5049a..b69bb32 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ var liveClient = new LiveClient(); var response = await liveClient.GetRadiationAndWeather( latitude: -33.856784, longitude: 151.215297, - output_parameters: ["air_temp", "dni", "ghi"] + outputParameters: ["air_temp", "dni", "ghi"] format: "csv" ); @@ -81,7 +81,7 @@ var forecastClient = new ForecastClient(); var response = await forecastClient.GetForecast( latitude: -33.856784, longitude: 151.215297, - output_parameters: ["air_temp", "dni", "ghi"] + outputParameters: ["air_temp", "dni", "ghi"] ); ``` diff --git a/docs/forecast.md b/docs/forecast.md index 653cb13..e72ad1e 100644 --- a/docs/forecast.md +++ b/docs/forecast.md @@ -35,7 +35,7 @@ dni,ghi,air_temp,period_end,period ## API Parameters - **latitude**: Latitude of the location in decimal degrees (north is positive). - **longitude**: Longitude of the location in decimal degrees (east is positive). -- **output_parameters**: An array of parameters to return, such as `dni`, `ghi`, `air_temp`. +- **outputParameters**: An array of parameters to return, such as `dni`, `ghi`, `air_temp`. - **format**: The format of the output (e.g., "json", "csv"). For more information about the forecast data API, visit the [Solcast API Docs](https://docs.solcast.com.au/#80627973-4183-4ebc-8a3d-1b2324fd1ed1). diff --git a/docs/live.md b/docs/live.md index 98ea385..3acea6a 100644 --- a/docs/live.md +++ b/docs/live.md @@ -34,7 +34,7 @@ dni,ghi,air_temp,period_end,period ## API Parameters - **latitude**: Latitude of the location in decimal degrees (north is positive). - **longitude**: Longitude of the location in decimal degrees (east is positive). -- **output_parameters**: An array of parameters to return, such as `dni`, `ghi`, `air_temp`. +- **outputParameters**: An array of parameters to return, such as `dni`, `ghi`, `air_temp`. - **format**: The format of the output (e.g., "json", "csv"). ---