diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 0000000..37500cb --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,94 @@ +name: Publish NuGet Packages + +on: + release: + types: [published] + +env: + Project_Name: Consequences/Consequences.csproj + +jobs: + build-windows: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4.1.7 + + - name: Setup .NET + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '8.x' + + - name: Create version number + shell: pwsh + run: | + $TAG = $env:GITHUB_REF -replace 'refs/tags/', '' + $VERSION = $TAG -replace '^v', '' + echo "VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Build for Windows x64 + run: dotnet publish ${{ env.PROJECT_NAME }} -c Release -r win-x64 --self-contained -p:PublishAot=true /p:PackageVersion=${{ env.VERSION }} + + - name: Pack NuGet packages + run: dotnet pack ${{ env.PROJECT_NAME }} -c Release /p:PackageVersion=${{ env.VERSION }} + + - name: Publish NuGet packages to GitHub Packages + run: dotnet nuget push **/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate + + - name: Upload Windows build artifact + uses: actions/upload-artifact@v4 + with: + name: USACE.HEC.Consequences-${{ env.VERSION }}-windows-x64 + path: ./Consequences/bin/Release/net8.0/win-x64/native/ + + - name: upload artifact to release + uses: actions/upload-release-asset@v1.0.2 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./Consequences/bin/Release/net8.0/win-x64/native/USACE.HEC.Consequences-${{ env.VERSION }}-windows-x64.zip + asset_name: USACE.HEC.Consequences-${{ env.VERSION }}-windows-x64 + asset_content_type: application/zip + + build-linux: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4.1.7 + + - name: Setup .NET + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '8.x' + + - name: Create version number + shell: bash + run: | + TAG=${GITHUB_REF#refs/tags/} + VERSION=${TAG#v} + echo "VERSION=${VERSION}" >> $GITHUB_ENV + + - name: Build for Linux x64 + run: dotnet publish ${{ env.PROJECT_NAME }} -c Release -r linux-x64 --self-contained -p:PublishAot=true /p:PackageVersion=${{ env.VERSION }} + + - name: Pack NuGet packages + run: dotnet pack ${{ env.PROJECT_NAME }} -c Release /p:PackageVersion=${{ env.VERSION }} + + - name: Publish NuGet packages to GitHub Packages + run: dotnet nuget push **/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate + + - name: Upload Linux build artifact + uses: actions/upload-artifact@v4 + with: + name: USACE.HEC.Consequences-${{ env.VERSION }}-linux-x64 + path: ./Consequences/bin/Release/net8.0/linux-x64/native/ + + - name: upload artifact to release + uses: actions/upload-release-asset@v1.0.2 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./Consequences/bin/Release/net8.0/linux-x64/native/USACE.HEC.Consequences-${{ env.VERSION }}-linux-x64.zip + asset_name: USACE.HEC.Consequences-${{ env.VERSION }}-linux-x64 + asset_content_type: application/zip + diff --git a/Consequences.sln b/Consequences.sln index e3e7b2c..e148dd9 100644 --- a/Consequences.sln +++ b/Consequences.sln @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .github\workflows\CI.yml = .github\workflows\CI.yml + .github\workflows\Release.yml = .github\workflows\Release.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsequencesTest", "ConsequencesTest\ConsequencesTest.csproj", "{95BCC49B-7780-41E9-8365-C51B5E1B3D5E}" diff --git a/Consequences/Consequences.csproj b/Consequences/Consequences.csproj index 746832b..ae3fea7 100644 --- a/Consequences/Consequences.csproj +++ b/Consequences/Consequences.csproj @@ -6,6 +6,7 @@ true true USACE.HEC + USACE.HEC.Consequences \ No newline at end of file diff --git a/Consequences/Consequences/NSIStreamingProcessor.cs b/Consequences/Consequences/NSIStreamingProcessor.cs index 2affd42..4f73997 100644 --- a/Consequences/Consequences/NSIStreamingProcessor.cs +++ b/Consequences/Consequences/NSIStreamingProcessor.cs @@ -47,6 +47,7 @@ private async Task ProcessCollection(BoundingBox boundingBox, Action