<commit_before>install:
  - set PATH=C:\Ruby23\bin;%PATH%
  - ps: mkdir c:\ca; iwr http://curl.haxx.se/ca/cacert.pem -outfile C:\ca\cacert.pem
  - set SSL_CERT_FILE=C:\ca\cacert.pem
  - ps: |
      $version = [version]$(cat VERSION)
      $build = $env:APPVEYOR_BUILD_NUMBER
      $major = $version.Major

      $branch = $env:APPVEYOR_REPO_BRANCH

      if ($branch -eq 'master') {
        $version = "$version-ci-$build"
      } elseif ($env:APPVEYOR_REPO_TAG) {
        $version = $env:APPVEYOR_REPO_TAG_NAME
      }
      else {
        $version = "$version-br-$branch-$build"
      }
      Set-AppveyorBuildVariable -Name "AssemblyMajor" -Value "$major"
      Update-AppVeyorBuild -Version "$version"

  - gem install chandler --no-ri --no-rdoc
  - ps: set-content ~/.netrc "machine api.github.com login $env:github_username password $env:github_password" -encoding ascii
  - ps: cp ~/.netrc ~/_netrc
  - chandler push

assembly_info:
  patch: false
  file: src\CommonInfo.cs
  assembly_version: $(AssemblyMajor).0.0.0
  assembly_file_version: '{version}'
  assembly_informational_version: '{version}'

configuration: Debug

platform: Any CPU

before_build:
  - pushd && cd src && nuget restore && popd

nuget:
  project_feed: true
  disable_publish_on_pr: true

build:
  parallel: true
  verbosity: minimal
  publish_nuget: true
  publish_nuget_symbols: true
  include_nuget_references: true
  project: src/ConsulStructure.sln

after_build:
  - pushd
  - cd %APPVEYOR_BUILD_FOLDER%
  - ps: |
      if ($env:APPVEYOR_REPO_TAG -eq $true) {
          cov-build.exe --dir cov-int make all
          nuget.exe install PublishCoverity -ExcludeVersion
          PublishCoverity\PublishCoverity.exe compress -o coverity.zip -i cov-int
          $version = $env:APPVEYOR_BUILD_VERSION
          PublishCoverity\PublishCoverity.exe publish `
            -t "$env:coverity_token" `
            -r "$env:APPVEYOR_REPO_NAME" `
            -z coverity.zip `
            -d "AppVeyor Tagged Build($env:APPVEYOR_BUILD_VERSION)." `
            --codeVersion "$version"
       }

  - ps: |
      $releaseNotes = 'Pre-release, see https://github.com/serialseb/ConsulStructure/blob/master/CHANGELOG.md for the latest details'
      echo "Repo tag: $env:APPVEYOR_REPO_TAG"
      if ($env:APPVEYOR_REPO_TAG -eq $true) {
        $uri = "https://api.github.com/repos/serialseb/ConsulStructure/releases/tags/$($env:APPVEYOR_REPO_TAG_NAME)?access_token=$($env:GITHUB_TOKEN)"
        echo "Loading from $uri"
        $releaseNotes = (Invoke-WebRequest -Uri $uri | convertfrom-json).body.Replace('"','\"')
        echo "Release notes: $releaseNotes"
        $nuspecPath = "$($env:APPVEYOR_BUILD_FOLDER)\ConsulStructure.nuspec"
        $nuspec = [xml](Get-Content $nuspecPath)
        $nuspec.package.metadata.releaseNotes = $releaseNotes
        $nuspec.Save($nuspecPath)
        echo "Saved file at $nuspecPath"
      }
      nuget pack ConsulStructure.nuspec -version $env:APPVEYOR_BUILD_VERSION -basepath $env:APPVEYOR_BUILD_FOLDER/src/ConsulStructure/

environment:
  SSL_CERT_FILE: C:\ca\cacert.pem
  COVERALLS_REPO_TOKEN:
    secure: <KEY>
  GITHUB_TOKEN:<commit_msg>Locks license to sha of the commit<commit_after>install:
  - set PATH=C:\Ruby23\bin;%PATH%
  - ps: mkdir c:\ca; iwr http://curl.haxx.se/ca/cacert.pem -outfile C:\ca\cacert.pem
  - set SSL_CERT_FILE=C:\ca\cacert.pem
  - ps: |
      $version = [version]$(cat VERSION)
      $build = $env:APPVEYOR_BUILD_NUMBER
      $major = $version.Major

      $branch = $env:APPVEYOR_REPO_BRANCH

      if ($branch -eq 'master') {
        $version = "$version-ci-$build"
      } elseif ($env:APPVEYOR_REPO_TAG) {
        $version = $env:APPVEYOR_REPO_TAG_NAME
      }
      else {
        $version = "$version-br-$branch-$build"
      }
      Set-AppveyorBuildVariable -Name "AssemblyMajor" -Value "$major"
      Update-AppVeyorBuild -Version "$version"

  - gem install chandler --no-ri --no-rdoc
  - ps: set-content ~/.netrc "machine api.github.com login $env:github_username password $env:github_password" -encoding ascii
  - ps: cp ~/.netrc ~/_netrc
  - chandler push

assembly_info:
  patch: false
  file: src\CommonInfo.cs
  assembly_version: $(AssemblyMajor).0.0.0
  assembly_file_version: '{version}'
  assembly_informational_version: '{version}'

configuration: Debug

platform: Any CPU

before_build:
  - pushd && cd src && nuget restore && popd

nuget:
  project_feed: true
  disable_publish_on_pr: true

build:
  parallel: true
  verbosity: minimal
  publish_nuget: true
  publish_nuget_symbols: true
  include_nuget_references: true
  project: src/ConsulStructure.sln

after_build:
  - pushd
  - cd %APPVEYOR_BUILD_FOLDER%
  - ps: |
      if ($env:APPVEYOR_REPO_TAG -eq $true) {
          cov-build.exe --dir cov-int make all
          nuget.exe install PublishCoverity -ExcludeVersion
          PublishCoverity\PublishCoverity.exe compress -o coverity.zip -i cov-int
          $version = $env:APPVEYOR_BUILD_VERSION
          PublishCoverity\PublishCoverity.exe publish `
            -t "$env:coverity_token" `
            -r "$env:APPVEYOR_REPO_NAME" `
            -z coverity.zip `
            -d "AppVeyor Tagged Build($env:APPVEYOR_BUILD_VERSION)." `
            --codeVersion "$version"
       }

  - ps: |
      $releaseNotes = 'Pre-release, see https://github.com/serialseb/ConsulStructure/blob/master/CHANGELOG.md for the latest details'
      echo "Repo tag: $env:APPVEYOR_REPO_TAG"
      $nuspecPath = "$($env:APPVEYOR_BUILD_FOLDER)\ConsulStructure.nuspec"
      $nuspec = [xml](Get-Content $nuspecPath)
      if ($env:APPVEYOR_REPO_TAG -eq $true) {
        $uri = "https://api.github.com/repos/serialseb/ConsulStructure/releases/tags/$($env:APPVEYOR_REPO_TAG_NAME)?access_token=$($env:GITHUB_TOKEN)"
        echo "Loading from $uri"
        $releaseNotes = (Invoke-WebRequest -Uri $uri | convertfrom-json).body.Replace('"','\"')
        echo "Release notes: $releaseNotes"
        $nuspec.package.metadata.releaseNotes = $releaseNotes
      }
      echo "Switching license to $env:APPVEYOR_REPO_COMMIT"
      $nuspec.package.metadata.licenseUrl = "https://github.com/serialseb/ConsulStructure/tree/$env:APPVEYOR_REPO_COMMIT/LICENSE.md"
      $nuspec.Save($nuspecPath)
      echo "Saved NuSpec at $nuspecPath"
      nuget pack ConsulStructure.nuspec -version $env:APPVEYOR_BUILD_VERSION -basepath $env:APPVEYOR_BUILD_FOLDER/src/ConsulStructure/

environment:
  SSL_CERT_FILE: C:\ca\cacert.pem
  COVERALLS_REPO_TOKEN:
    secure: <KEY>
  GITHUB_TOKEN:
{'fraction_non_alphanumeric': 0.12304147465437788, 'fraction_numerical': 0.0015360983102918587, 'mean_word_length': 3.128725428027901, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '287448', 'n_tokens_mistral': 2379, 'n_tokens_neox': 2363, 'n_words': 422}