lepton_jpeg 0.4.0

Rust port of the Lepton JPEG compression library
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- main

pool:
  name: Azure Pipelines
  vmImage: windows-latest

steps:
- task: ssplat.rust-build-release-tools.rust-installer-task.RustInstaller@1
  displayName: 'Install Rust '
  inputs:
    rustVersion: 'ms-1.81'
    additionalTargets: 'i686-pc-windows-msvc'
    toolchainFeed: https://onedrive.pkgs.visualstudio.com/b52099a6-3b13-4b08-9270-a07884a10e3d/_packaging/RustTools/nuget/v3/index.json
    cratesIoFeedOverride: sparse+https://onedrive.pkgs.visualstudio.com/b52099a6-3b13-4b08-9270-a07884a10e3d/_packaging/RustCratesIO/Cargo/index/

- script: |

   cargo build --locked 2>&1
   
  displayName: 'Build debug'

- script: |

   cargo install junit-test
   junit-test
   copy junit.xml $(System.DefaultWorkingDirectory)\TEST-rust.xml
  displayName: 'Test debug'

- task: PublishTestResults@2
  displayName: 'Publish Test Results **/TEST-*.xml'
  inputs:
    mergeTestResults: true

- script: |

   set RUSTFLAGS=-Ccontrol-flow-guard -Ctarget-feature=+crt-static,+avx2,+lzcnt -Clink-args=/DYNAMICBASE/CETCOMPAT
   cargo build --locked --release 2>&1
   copy target\release\lepton_jpeg.dll target\release\lepton_jpeg_avx2.dll
   copy target\release\lepton_jpeg.pdb target\release\lepton_jpeg_avx2.pdb
   copy target\release\lepton_jpeg_util.exe target\release\lepton_jpeg_util_avx2.exe
   copy target\release\lepton_jpeg_util.pdb target\release\lepton_jpeg_util_avx2.pdb
   set RUSTFLAGS=-Ccontrol-flow-guard -Ctarget-feature=+crt-static -Clink-args=/DYNAMICBASE/CETCOMPAT
   cargo build --locked --release 2>&1

  displayName: 'Build Release'

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '6.x'

- task: EsrpCodeSigning@5
  inputs:
    ConnectedServiceName: 'ESRP CodeSigningV2-OneDrive Service'
    AppRegistrationClientId: 'bd3fbc52-4cf5-4cca-a25d-94160e5ed309' 
    AppRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' 
    AuthAKVName: 'ODSP-ESRP' 
    AuthCertName: 'ODSP-ESRP-Auth-V2' 
    AuthSignCertName: 'CodeSigningCertificate'
    FolderPath: '$(Build.SourcesDirectory)'
    Pattern: '
      target\debug\lepton_jpeg.dll,
      target\debug\lepton_jpeg_util.exe,
      target\release\lepton_jpeg.dll,
      target\release\lepton_jpeg_avx2.dll,
      target\release\lepton_jpeg_util.exe,
      target\release\lepton_jpeg_util_avx2.exe'
    signConfigType: 'inlineSignParams'
    inlineOperation: |

      [
       {
        "KeyCode": "CP-401405",
        "OperationCode": "SigntoolSign",
        "ToolName": "sign",
        "ToolVersion": "1.0",
        "Parameters": {
         "OpusName": "Microsoft",
         "OpusInfo": "https://www.microsoft.com",
         "FileDigest": "/fd SHA256",
         "PageHash": "/NPH",
         "TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
        }
       },
       {
        "KeyCode": "CP-401405",
        "OperationCode": "SigntoolVerify",
        "ToolName": "sign",
        "ToolVersion": "1.0",
        "Parameters": {}
       }
      ]
    SessionTimeout: '60'
    MaxConcurrency: '50'
    MaxRetryAttempts: '5'
    PendingAnalysisWaitTimeoutMinutes: '5'

- task: CopyFiles@2
  displayName: 'Copy Rust output files to: $(Build.ArtifactStagingDirectory) copy'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: |

     target\debug\?(*.dll|*.exe|*.pdb)
     target\release\?(*.dll|*.exe|*.pdb)
     
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    ArtifactName: 'drop_lepton_jpeg_rust'

- task: PublishSymbols@2
  displayName: 'Publish symbols copy'
  inputs:
    SymbolsFolder: '$(Build.ArtifactStagingDirectory)'
    SearchPattern: '**\*.pdb'
    SymbolServerType: TeamServices

- task: NuGetCommand@2
  displayName: 'NuGet pack'
  inputs:
    command: pack
    packagesToPack: package/Lepton.Jpeg.Rust.nuspec

- task: NuGetCommand@2
  displayName: 'NuGet push'
  inputs:
    command: push
    packagesToPush: '$(Build.ArtifactStagingDirectory)\*.nupkg'
    publishVstsFeed: 'b87285d9-99ab-48db-a000-cb0cc8a2a1b5'
    allowPackageConflicts: true
  condition: and(succeeded(), in(variables['Build.Reason'], 'Manual'), eq(variables['Build.SourceBranch'], 'main'))