<commit_before>name: CI_CD

on:
  workflow_dispatch:

  push:
    paths-ignore:
    - "**/*.md"
    - "**/*.gitignore"
    - "**/*.gitattributes"

  pull_request:
    branches:
      - main

  release:
    types:
      - published

env:
  # more info on dotnet cli environment variables here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables
  # Disable sending usage data to Microsoft
  DOTNET_CLI_TELEMETRY_OPTOUT: true
  # Disable welcome message on dotnet CLI first run
  DOTNET_NOLOGO: true
  # Disable redundant package caching
  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

jobs:
  build_and_test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 10
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Set up dotnet 
      uses: actions/setup-dotnet@v2
      with:
        dotnet-version: |
         3.1.x
         5.0.x
         6.0.x

    - uses: actions/cache@v3
      with:
        path: ~/.nuget/packages
        key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
        restore-keys: |
          ${{ runner.os }}-nuget-

    - name: Install dependencies
      run: |
        dotnet restore

    - name: Build
      run: |
        dotnet build --configuration Release --version-suffix "$GITHUB_RUN_ID-prerelease" --no-restore

    - name: Run tests on mac and linux
      if: ${{ !startsWith(matrix.os, 'windows') }}
      env:
        TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
      run: |
        dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1
        dotnet test --configuration Release --no-build --verbosity normal --framework net5.0
        dotnet test --configuration Release --no-build --verbosity normal --framework net6.0

    - name: Run tests on windows
      if: startsWith(matrix.os, 'windows')
      env:
        TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
      run: |
        dotnet test --configuration Release --no-build --verbosity normal

  deploy:
    needs: build_and_test
    if: github.event_name == 'release'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up dotnet 
        uses: actions/setup-dotnet@v2
        with:
          dotnet-version: 6.0.x

      - name: Create Release NuGet package
        run: |
          arrTag=(${GITHUB_REF//\// })
          VERSION="${arrTag[2]}"
          VERSION="${VERSION//v}"
          echo Clean Version: $VERSION
          dotnet pack src/Tinify/Tinify.csproj -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -p:PackageId=Tinify-netstandard20 -o .

      - name: Push to Nuget
        run: |
          dotnet nuget push *.nupkg --skip-duplicate -s https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}}<commit_msg>Removed temporary nuget package name moniker, and reset to tinify official<commit_after>name: CI_CD

on:
  workflow_dispatch:

  push:
    paths-ignore:
    - "**/*.md"
    - "**/*.gitignore"
    - "**/*.gitattributes"

  pull_request:
    branches:
      - main

  release:
    types:
      - published

env:
  # more info on dotnet cli environment variables here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables
  # Disable sending usage data to Microsoft
  DOTNET_CLI_TELEMETRY_OPTOUT: true
  # Disable welcome message on dotnet CLI first run
  DOTNET_NOLOGO: true
  # Disable redundant package caching
  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

jobs:
  build_and_test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 10
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Set up dotnet 
      uses: actions/setup-dotnet@v2
      with:
        dotnet-version: |
         3.1.x
         5.0.x
         6.0.x

    - uses: actions/cache@v3
      with:
        path: ~/.nuget/packages
        key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
        restore-keys: |
          ${{ runner.os }}-nuget-

    - name: Install dependencies
      run: |
        dotnet restore

    - name: Build
      run: |
        dotnet build --configuration Release --version-suffix "$GITHUB_RUN_ID-prerelease" --no-restore

    - name: Run tests on mac and linux
      if: ${{ !startsWith(matrix.os, 'windows') }}
      env:
        TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
      run: |
        dotnet test --configuration Release --no-build --verbosity normal --framework netcoreapp3.1
        dotnet test --configuration Release --no-build --verbosity normal --framework net5.0
        dotnet test --configuration Release --no-build --verbosity normal --framework net6.0

    - name: Run tests on windows
      if: startsWith(matrix.os, 'windows')
      env:
        TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
      run: |
        dotnet test --configuration Release --no-build --verbosity normal

  deploy:
    needs: build_and_test
    if: github.event_name == 'release'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up dotnet 
        uses: actions/setup-dotnet@v2
        with:
          dotnet-version: 6.0.x

      - name: Create Release NuGet package
        run: |
          arrTag=(${GITHUB_REF//\// })
          VERSION="${arrTag[2]}"
          VERSION="${VERSION//v}"
          echo Clean Version: $VERSION
          dotnet pack src/Tinify/Tinify.csproj -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o .

      - name: Push to Nuget
        run: |
          dotnet nuget push *.nupkg --skip-duplicate -s https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}}
{'fraction_non_alphanumeric': 0.12248009486701678, 'fraction_numerical': 0.008470269354565475, 'mean_word_length': 2.1139240506329116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5365868', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1886, 'n_words': 466}