diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4358f279..d9b1e881 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,20 +71,20 @@ jobs: json: true github-bearer-token: ${{ secrets.GITHUB_TOKEN }} - - name: Publish package to NuGet - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: | - dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ${{ steps.package_release.outputs.package_filename }} - - - name: Publish Docker image to Docker Hub - env: - DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} - run: | - REPO=cyclonedx/cyclonedx-dotnet - docker login --username coderpatros --password "$DOCKER_TOKEN" - docker push $REPO:latest - docker push $REPO:${{ steps.package_release.outputs.version }} +# - name: Publish package to NuGet +# env: +# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} +# run: | +# dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ${{ steps.package_release.outputs.package_filename }} +# +# - name: Publish Docker image to Docker Hub +# env: +# DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} +# run: | +# REPO=cyclonedx/cyclonedx-dotnet +# docker login --username coderpatros --password "$DOCKER_TOKEN" +# docker push $REPO:latest +# docker push $REPO:${{ steps.package_release.outputs.version }} - name: Create github release and git tag for release id: create_release diff --git a/CycloneDX/Services/NugetV3Service.cs b/CycloneDX/Services/NugetV3Service.cs index 4dde3c55..6d1cd91f 100644 --- a/CycloneDX/Services/NugetV3Service.cs +++ b/CycloneDX/Services/NugetV3Service.cs @@ -20,6 +20,8 @@ using System.Diagnostics.Contracts; using System.IO; using System.IO.Abstractions; +using System.IO.Compression; +using System.Net.Http; using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; @@ -306,23 +308,53 @@ private static Component SetupComponentProperties(Component component, NuspecMod return component; } - private async Task GetNuspec(string name, string version, string nuspecFilename, - FindPackageByIdResource resource) + private async Task GetNuspec(string name, string version, string nuspecFilename, FindPackageByIdResource resource) { var nuspecModel = new NuspecModel(); if (nuspecFilename == null) { - var packageVersion = new NuGetVersion(version); - await using MemoryStream packageStream = new MemoryStream(); - await resource.CopyNupkgToStreamAsync(name, packageVersion, packageStream, _sourceCacheContext, - _logger, _cancellationToken); + try + { + var packageVersion = new NuGetVersion(version); + + + //using (MemoryStream ms = new MemoryStream()) + //{ + // // Create new ZIP archive within prepared MemoryStream + // using (ZipArchive zip = new ZipArchive(ms, ZipArchiveMode.Create, true)) + // { + // zip.CreateEntry(logoimage); + // // ... + // } + // ms.WriteTo(HttpContext.Current.Response.OutputStream); + //} + var doesPackageExist = await resource.DoesPackageExistAsync(name, packageVersion, _sourceCacheContext, _logger, _cancellationToken); + if(doesPackageExist) + { + await using MemoryStream packageStream = new MemoryStream(); + await resource.CopyNupkgToStreamAsync(name, packageVersion, packageStream, _sourceCacheContext, _logger, _cancellationToken); + //await resource.CopyNupkgToStreamAsync(name, packageVersion, packageStream, _sourceCacheContext,_logger, _cancellationToken); - using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream); - nuspecModel.nuspecReader = await packageReader.GetNuspecReaderAsync(_cancellationToken); + using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream); + nuspecModel.nuspecReader = await packageReader.GetNuspecReaderAsync(_cancellationToken); - if (!_disableHashComputation) + if (!_disableHashComputation) + { + nuspecModel.hashBytes = ComputeSha215Hash(packageStream); + } + } + else + { + Console.WriteLine($"Package {name} {version} does not exist on {_sourceRepository.PackageSource.Source}"); + } + + } + catch (Exception ex) { - nuspecModel.hashBytes = ComputeSha215Hash(packageStream); + Console.WriteLine($"Error while processing package {name} {version}"); + _logger.LogError($"Error while processing package {name} {version}"); + _logger.LogError(ex.Message); + _logger.LogError(ex.StackTrace); } } else diff --git a/semver.txt b/semver.txt index dbe59006..1817afea 100755 --- a/semver.txt +++ b/semver.txt @@ -1 +1 @@ -2.8.1 +2.8.2