<commit_before>name: Publish code

on:
  release:
    types:
      - published

env:
  NODE_VERSION: '10.x'   # Node 10 LTS

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Check github.ref starts with 'refs/tags/'
        if: ${{ !startsWith(github.ref, 'refs/tags/') }}
        run: |
          echo Error! github.ref does not start with 'refs/tags'
          echo github.ref: ${{ github.ref }}
          exit 1
      - name: Set version number environment variable
        env:
          github_ref: ${{ github.ref }}
        run: |
          ref="${github_ref:10}"
          echo $ref
          echo "ref=$ref" >> $GITHUB_ENV
      - name: Use Node.js ${{ env.NODE_VERSION }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ env.NODE_VERSION }}
      - name: yarn
        run: yarn
      - name: yarn docs2
        working-directory: docs2
        run: yarn
      - name: yarn gatsby build
        working-directory: docs2
        run: yarn gatsby build
      - name: Publish docs artifacts
        uses: actions/upload-artifact@v2
        with:
          name: Documentation
          path: docs2/public/**
          if-no-files-found: error
      - name: Use .NET Core 3.1 SDK
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '3.1.x'
          source-url: https://api.nuget.org/v3/index.json
        env:
          NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
      - name: Install dependencies
        working-directory: src
        run: dotnet restore
        env:
          DOTNET_NOLOGO: true
          DOTNET_CLI_TELEMETRY_OPTOUT: true
      - name: Build solution (release config)
        working-directory: src
        run: dotnet build --no-restore -c Release -p:NoWarn=CS1591 -p:Version=$ref
      - name: Pack solution (release config)
        working-directory: src
        run: dotnet pack --no-restore -c Release -p:Version=$ref -o out
      - name: Publish artifacts
        uses: actions/upload-artifact@v2
        with:
          name: Nuget packages
          path: |
            src/out/*
      - name: Publish Nuget packages to Nuget registry
        working-directory: src
        run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}}<commit_msg>Add docs and packages to release artifacts (#1956)<commit_after>name: Publish code

on:
  release:
    types:
      - published

env:
  NODE_VERSION: '10.x'   # Node 10 LTS

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Check github.ref starts with 'refs/tags/'
        if: ${{ !startsWith(github.ref, 'refs/tags/') }}
        run: |
          echo Error! github.ref does not start with 'refs/tags'
          echo github.ref: ${{ github.ref }}
          exit 1
      - name: Set version number environment variable
        env:
          github_ref: ${{ github.ref }}
        run: |
          ref="${github_ref:10}"
          echo $ref
          echo "ref=$ref" >> $GITHUB_ENV
      - name: Use Node.js ${{ env.NODE_VERSION }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ env.NODE_VERSION }}
      - name: yarn
        run: yarn
      - name: yarn docs2
        working-directory: docs2
        run: yarn
      - name: yarn gatsby build
        working-directory: docs2
        run: yarn gatsby build
      - name: Upload documentation as workflow artifacts
        uses: actions/upload-artifact@v2
        with:
          name: Documentation
          path: docs2/public/**
          if-no-files-found: error
      - name: Use .NET Core 3.1 SDK
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '3.1.x'
          source-url: https://api.nuget.org/v3/index.json
        env:
          NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
      - name: Install dependencies
        working-directory: src
        run: dotnet restore
        env:
          DOTNET_NOLOGO: true
          DOTNET_CLI_TELEMETRY_OPTOUT: true
      - name: Build solution (release config)
        working-directory: src
        run: dotnet build --no-restore -c Release -p:NoWarn=CS1591 -p:Version=$ref
      - name: Pack solution (release config)
        working-directory: src
        run: dotnet pack --no-restore -c Release -p:Version=$ref -o out
      - name: Upload nuget packages as workflow artifacts
        uses: actions/upload-artifact@v2
        with:
          name: Nuget packages
          path: |
            src/out/*
      - name: Publish Nuget packages to Nuget registry
        working-directory: src
        run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}}
      - name: Zip documentation
        working-directory: docs2/public
        run: zip -r ../../src/out/Documentation.zip "./*"
      - name: Upload nuget packages and documentation as release artifacts
        uses: actions/github-script@v2
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            console.log('environment', process.versions);
            const fs = require('fs').promises;
            const { repo: { owner, repo }, sha } = context;

            for (let file of await fs.readdir('src/out')) {
              console.log('uploading', file);

              await github.repos.uploadReleaseAsset({
                owner,
                repo,
                release_id: ${{ github.event.release.id }},
                name: file,
                data: await fs.readFile(`src/out/${file}`)
              });
            }
{'fraction_non_alphanumeric': 0.10831234256926953, 'fraction_numerical': 0.010075566750629723, 'mean_word_length': 1.7642963699651915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4131891', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1637, 'n_words': 444}