<commit_before>name: goreleaser

on:
  pull_request:
  push:

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Unshallow (for CHANGELOG)
      run: git fetch --prune --unshallow

    - uses: actions/setup-go@v1
      with:
        go-version: 1.x

    - run: sudo apt-get install -y silversearcher-ag  # For goolint.sh
    - name: Verify
      run: |
        [[ $(git grep -l pwdID | wc -l) = 2 ]]  # lint: pwdID fiddling happens only in one place
        ag --version
        make lint
        go vet ./...
        go mod tidy
        go mod verify
        make test.ci
        git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]]

    - name: Set CURRENT_TAG
      run: |
        CURRENT_TAG=M.m.p
        if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then CURRENT_TAG=${GITHUB_REF#refs/tags/}; fi
        echo "::set-env name=CURRENT_TAG::$CURRENT_TAG"

    - name: Build
      uses: goreleaser/goreleaser-action@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        version: latest # FIXME: https://github.com/goreleaser/goreleaser-action/issues/157
        args: release --rm-dist --snapshot --skip-publish

    - name: Test
      run: |
        tar zxvf ./dist/monkey-Linux-x86_64.tar.gz -C .
        SHORT_COMMIT=$(cut -c-7 <<<$GITHUB_SHA)
        ./monkey -h | grep $SHORT_COMMIT
        ./monkey help | grep monkey
        ./monkey version
        [[ $(./monkey version | wc -l) = 1 ]]
        ./monkey version | grep $CURRENT_TAG
        ./monkey --version | grep $SHORT_COMMIT
        rm ./monkey

    - name: Publish
      uses: goreleaser/goreleaser-action@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        version: latest # FIXME: https://github.com/goreleaser/goreleaser-action/issues/157
        args: release --rm-dist
      if: startsWith(github.ref, 'refs/tags/')


  install-on-ubuntu:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: goreleaser
    steps:
    - run: echo $PATH
    - run: 'while read -d: -r path; do ls -lhd $path; done <<<"$PATH"'
    # - run: echo "::add-path::/path/to/dir"
    - run: '! which monkey'
    - run: '! monkey help'
    - run: curl -#fL https://git.io/FuzzyMonkey | BINDIR=/usr/bin sh -ex
    - run: monkey help
    - run: monkey version

  install-on-macos:
    runs-on: macos-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: goreleaser
    steps:
    - run: echo $PATH
    - run: 'while read -d: -r path; do ls -lhd $path; done <<<"$PATH"'
    - run: '! which monkey'
    - run: '! monkey help'
    - run: curl -#fL https://git.io/FuzzyMonkey | BINDIR=/usr/local/bin sh -ex
    - run: monkey help
    - run: monkey version

  install-on-windows:
    runs-on: windows-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: goreleaser
    steps:
    - run: echo $PATH
      shell: bash
    - run: 'while read -d: -r path; do ls -lhd $path; done <<<"$PATH"'
      shell: bash
    - run: '! which monkey'
      shell: bash
    - run: '! monkey help'
      shell: bash
    - run: curl -#fL https://git.io/FuzzyMonkey | BINDIR=/c/npm/prefix sh -ex
      shell: bash
    - run: monkey help
      shell: bash
    - run: monkey version
      shell: bash<commit_msg>ci: fix testing installation on ubuntu<commit_after>name: goreleaser

on:
  pull_request:
  push:

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Unshallow (for CHANGELOG)
      run: git fetch --prune --unshallow

    - uses: actions/setup-go@v1
      with:
        go-version: 1.x

    - run: sudo apt-get install -y silversearcher-ag  # For goolint.sh
    - name: Verify
      run: |
        [[ $(git grep -l pwdID | wc -l) = 2 ]]  # lint: pwdID fiddling happens only in one place
        ag --version
        make lint
        go vet ./...
        go mod tidy
        go mod verify
        make test.ci
        git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]]

    - name: Set CURRENT_TAG
      run: |
        CURRENT_TAG=M.m.p
        if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then CURRENT_TAG=${GITHUB_REF#refs/tags/}; fi
        echo "::set-env name=CURRENT_TAG::$CURRENT_TAG"

    - name: Build
      uses: goreleaser/goreleaser-action@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        version: latest # FIXME: https://github.com/goreleaser/goreleaser-action/issues/157
        args: release --rm-dist --snapshot --skip-publish

    - name: Test
      run: |
        tar zxvf ./dist/monkey-Linux-x86_64.tar.gz -C .
        SHORT_COMMIT=$(cut -c-7 <<<$GITHUB_SHA)
        ./monkey -h | grep $SHORT_COMMIT
        ./monkey help | grep monkey
        ./monkey version
        [[ $(./monkey version | wc -l) = 1 ]]
        ./monkey version | grep $CURRENT_TAG
        ./monkey --version | grep $SHORT_COMMIT
        rm ./monkey

    - name: Publish
      uses: goreleaser/goreleaser-action@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        version: latest # FIXME: https://github.com/goreleaser/goreleaser-action/issues/157
        args: release --rm-dist
      if: startsWith(github.ref, 'refs/tags/')


  install-on-ubuntu:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: goreleaser
    steps:
    - run: echo $PATH
    - run: 'while read -d: -r path; do ls -lhd $path || echo $path; done <<<"$PATH"'
    - run: '! which monkey'
    - run: '! monkey help'
    - run: curl -#fL https://git.io/FuzzyMonkey | BINDIR=/usr/share/rust/.cargo/bin sh -ex
    - run: monkey help
    - run: monkey version

  install-on-macos:
    runs-on: macos-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: goreleaser
    steps:
    - run: echo $PATH
    - run: 'while read -d: -r path; do ls -lhd $path || echo $path; done <<<"$PATH"'
    - run: '! which monkey'
    - run: '! monkey help'
    - run: curl -#fL https://git.io/FuzzyMonkey | BINDIR=/usr/local/bin sh -ex
    - run: monkey help
    - run: monkey version

  install-on-windows:
    runs-on: windows-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: goreleaser
    steps:
    - run: echo $PATH
      shell: bash
    - run: 'while read -d: -r path; do ls -lhd $path || echo $path; done <<<"$PATH"'
      shell: bash
    - run: '! which monkey'
      shell: bash
    - run: '! monkey help'
      shell: bash
    - run: curl -#fL https://git.io/FuzzyMonkey | BINDIR=/c/npm/prefix sh -ex
      shell: bash
    - run: monkey help
      shell: bash
    - run: monkey version
      shell: bash
{'fraction_non_alphanumeric': 0.14313666465984345, 'fraction_numerical': 0.005719446116797111, 'mean_word_length': 1.9758172861621137, 'pattern_counts': {'":': 3, '<': 27, '<?xml version=': 0, '>': 3, 'https://': 10, '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': '796132', 'n_tokens_mistral': 2534, 'n_tokens_neox': 2393, 'n_words': 619}