<commit_before>name: Build
on: 
  push:
    branches:
    - master
    tags:
    - v2.*
    paths:
    - '**'
    - '!.github/**'
    
jobs:              
  build-binaries:
    name: Build Binaries
    runs-on: ubuntu-18.04
    
    strategy:
      matrix:
        os: [ linux, windows ]
        arch: [ amd64, arm ]
        go: [ '1.13' ]
        exclude:
          - os: windows
            arch: arm

    env:
      GOOS: ${{ matrix.os }}
      GOARCH: ${{ matrix.arch }}

    steps:
    - name: Get the version
      run: echo "::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}"
    
    - name: Get the version
      if: startsWith(env.VERSION, 'refs/')
      run: echo "::set-env name=VERSION::${GITHUB_REF/refs\/heads\//}"

    - name: Set up Go ${{ matrix.go }}
      uses: actions/setup-go@v1
      with:
        go-version: ${{ matrix.go }}

    - name: Check out code into the Go module directory
      uses: actions/checkout@v1
      with:
        path: pufferpanel
        
    - name: Build
      if: startsWith(matrix.os, 'linux')
      run: |
        go build -o pufferpanel -ldflags "-X github.com/pufferpanel/pufferpanel/version.Hash=${{ github.sha }} -X github.com/pufferpanel/pufferpanel/version.Version=${{ env.VERSION }}" -v github.com/pufferpanel/pufferpanel/v2/cmd

    - name: Build
      if: startsWith(matrix.os, 'windows')
      run: |
        go build -o pufferpanel.exe -ldflags "-X github.com/pufferpanel/pufferpanel/version.Hash=${{ github.sha }} -X github.com/pufferpanel/pufferpanel/version.Version=${{ env.VERSION }}" -v github.com/pufferpanel/pufferpanel/v2/cmd

    - name: Publish Binary
      uses: actions/upload-artifact@v1
      if: startsWith(matrix.os, 'linux') && startsWith(github.ref, 'refs/tags/v2.')
      with:
        name: ${{ matrix.os }} ${{ matrix.arch }} - Binary
        path: pufferpanel

    - name: Publish Binary
      uses: actions/upload-artifact@v1
      if: startsWith(matrix.os, 'windows') && startsWith(github.ref, 'refs/tags/v2.')
      with:
        name: ${{ matrix.os }} ${{ matrix.arch }} - Binary
        path: pufferpanel.exe

  produce-webartifacts:
    name: Generate web artifacts
    runs-on: ubuntu-18.04

    strategy:
      matrix:
        node-version: [ '12.x' ]

    steps:
      - name: Set up Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Check out code into the Go module directory
        uses: actions/checkout@v1

      - name: npm install, build
        run: |
          npm install
          npm run build
        env:
          CI: true
        working-directory: client

      - name: Publish Supporting
        uses: actions/upload-artifact@v1
        if: startsWith(github.ref, 'refs/tags/v2.')
        with:
          name: Web Artifacts
          path: client/dist

  produce-release:
    name: Generate packages artifacts
    runs-on: ubuntu-18.04
    needs: [produce-webartifacts,build-binaries]
    if: startsWith(github.ref, 'refs/tags/v2.')
        
    steps:
      - name: Get the version
        run: echo "::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}"  
      
      - uses: actions/setup-ruby@v1
        
      - name: Install gems
        run: |
          gem install --no-doc rake
          gem install --no-doc fpm
          gem install --no-doc package_cloud
          
      - name: Pull main repo
        uses: actions/checkout@v1
        with:
          path: pufferpanel
          
      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: linux amd64 - Binary
          path: binaries/amd64 

      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: windows amd64 - Binary
          path: binaries/amd64 
          
      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: linux arm - Binary
          path: binaries/arm 
        
      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: Web Artifacts
          path: www/pufferpanel
          
      - name: Fix perms on files
        run: |
          chmod +x binaries/amd64/pufferpanel
          chmod +x binaries/arm/pufferpanel
          
      - name: Build packages
        run: |
          mkdir build
          
          fpm -s dir -t deb \
          --name pufferpanel -v ${{ env.VERSION }} \
          --maintainer <EMAIL> \
          --deb-user pufferpanel --deb-group pufferpanel \
          --deb-systemd ../pufferpanel/systemd/servicefiles/systemd/pufferpanel \
          --before-install ../pufferpanel/systemd/scripts/preinst.sh \
          --after-upgrade ../pufferpanel/systemd/scripts/postupgrade.sh \
          --before-remove ../pufferpanel/systemd/scripts/prerm.sh \
          --deb-after-purge ../pufferpanel/systemd/scripts/purge.sh \
          binaries/amd64/pufferpanel=/usr/sbin/pufferpanel \
          www/pufferpanel=/var/www \
          ../pufferpanel/assets/email=/etc/pufferpanel \
          ../pufferpanel/config.linux.json=/etc/pufferpanel/config.json
          
          mv *.deb build/
          
          fpm -s deb -t rpm \
          --name pufferpanel \
          --maintainer <EMAIL> \
          --rpm-user pufferpanel --rpm-group pufferpanel \
          --before-install ../pufferpanel/systemd/scripts/preinst.sh \
          --after-upgrade ../pufferpanel/systemd/scripts/postupgrade.sh \
          --before-remove ../pufferpanel/systemd/scripts/prerm.sh \
          build/pufferpanel_*_amd64.deb

          mv *.rpm build/
          
          fpm -s dir -t deb \
          --name pufferpanel -v ${{ env.VERSION }} \
          --maintainer <EMAIL> \
          --deb-user pufferpanel --deb-group pufferpanel \
          --deb-systemd ../pufferpanel/systemd/servicefiles/systemd/pufferpanel \
          --before-install ../pufferpanel/systemd/scripts/preinst.sh \
          --after-upgrade ../pufferpanel/systemd/scripts/postupgrade.sh \
          --before-remove ../pufferpanel/systemd/scripts/prerm.sh \
          --deb-after-purge ../pufferpanel/systemd/scripts/purge.sh \
          -a armhf \
          binaries/arm/pufferpanel=/usr/sbin/pufferpanel \
          www/pufferpanel=/var/www \
          ../pufferpanel/assets/email=/etc/pufferpanel/email \
          ../pufferpanel/config.linux.json=/etc/pufferpanel/config.json
          
          mv *.deb build/
          <commit_msg>Update build.yml<commit_after>name: Build
on: 
  push:
    branches:
    - master
    tags:
    - v2.*
    paths:
    - '**'
    - '!.github/**'
    
jobs:              
  build-binaries:
    name: Build Binaries
    runs-on: ubuntu-18.04
    
    strategy:
      matrix:
        os: [ linux, windows ]
        arch: [ amd64, arm ]
        go: [ '1.13' ]
        exclude:
          - os: windows
            arch: arm

    env:
      GOOS: ${{ matrix.os }}
      GOARCH: ${{ matrix.arch }}

    steps:
    - name: Get the version
      run: echo "::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}"
    
    - name: Get the version
      if: startsWith(env.VERSION, 'refs/')
      run: echo "::set-env name=VERSION::${GITHUB_REF/refs\/heads\//}"

    - name: Set up Go ${{ matrix.go }}
      uses: actions/setup-go@v1
      with:
        go-version: ${{ matrix.go }}

    - name: Check out code into the Go module directory
      uses: actions/checkout@v1
      with:
        path: pufferpanel
        
    - name: Build
      if: startsWith(matrix.os, 'linux')
      run: |
        go build -o pufferpanel -ldflags "-X github.com/pufferpanel/pufferpanel/version.Hash=${{ github.sha }} -X github.com/pufferpanel/pufferpanel/version.Version=${{ env.VERSION }}" -v github.com/pufferpanel/pufferpanel/v2/cmd

    - name: Build
      if: startsWith(matrix.os, 'windows')
      run: |
        go build -o pufferpanel.exe -ldflags "-X github.com/pufferpanel/pufferpanel/version.Hash=${{ github.sha }} -X github.com/pufferpanel/pufferpanel/version.Version=${{ env.VERSION }}" -v github.com/pufferpanel/pufferpanel/v2/cmd

    - name: Publish Binary
      uses: actions/upload-artifact@v1
      if: startsWith(matrix.os, 'linux') && startsWith(github.ref, 'refs/tags/v2.')
      with:
        name: ${{ matrix.os }} ${{ matrix.arch }} - Binary
        path: pufferpanel

    - name: Publish Binary
      uses: actions/upload-artifact@v1
      if: startsWith(matrix.os, 'windows') && startsWith(github.ref, 'refs/tags/v2.')
      with:
        name: ${{ matrix.os }} ${{ matrix.arch }} - Binary
        path: pufferpanel.exe

  produce-webartifacts:
    name: Generate web artifacts
    runs-on: ubuntu-18.04

    strategy:
      matrix:
        node-version: [ '12.x' ]

    steps:
      - name: Set up Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Check out code into the Go module directory
        uses: actions/checkout@v1

      - name: npm install, build
        run: |
          npm install
          npm run build
        env:
          CI: true
        working-directory: client

      - name: Publish Supporting
        uses: actions/upload-artifact@v1
        if: startsWith(github.ref, 'refs/tags/v2.')
        with:
          name: Web Artifacts
          path: client/dist

  produce-release:
    name: Generate packages artifacts
    runs-on: ubuntu-18.04
    needs: [produce-webartifacts,build-binaries]
    if: startsWith(github.ref, 'refs/tags/v2.')
        
    steps:
      - name: Get the version
        run: echo "::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}"  
      
      - uses: actions/setup-ruby@v1
        
      - name: Install gems
        run: |
          gem install --no-doc rake
          gem install --no-doc fpm
          gem install --no-doc package_cloud
          
      - name: Pull main repo
        uses: actions/checkout@v1
        with:
          path: pufferpanel
          
      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: linux amd64 - Binary
          path: binaries/amd64 

      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: windows amd64 - Binary
          path: binaries/amd64 
          
      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: linux arm - Binary
          path: binaries/arm 
        
      - name: Pull files
        uses: actions/download-artifact@v1
        with:
          name: Web Artifacts
          path: www/pufferpanel
          
      - name: Fix perms on files
        run: |
          chmod +x binaries/amd64/pufferpanel
          chmod +x binaries/arm/pufferpanel
          
      - name: Build packages
        run: |
          mkdir build
          
          fpm -s dir -t deb \
          --name pufferpanel -v ${{ env.VERSION }} \
          --maintainer <EMAIL> \
          --deb-user pufferpanel --deb-group pufferpanel \
          --deb-systemd ../pufferpanel/systemd/servicefiles/pufferpanel.service \
          --before-install ../pufferpanel/systemd/scripts/preinstall.sh \
          --after-install ../pufferpanel/systemd/scripts/postinstall.sh \
          --after-upgrade ../pufferpanel/systemd/scripts/postupgrade.sh \
          --before-remove ../pufferpanel/systemd/scripts/prerm.sh \
          --after-remove ../pufferpanel/systemd/scripts/postremove.sh \
          --deb-after-purge ../pufferpanel/systemd/scripts/purge.sh \
          binaries/amd64/pufferpanel=/usr/sbin/pufferpanel \
          www/pufferpanel=/var/www \
          var/log/pufferpanel=/var/log \
          var/lib/pufferpanel=/var/lib \
          ../pufferpanel/assets/email=/etc/pufferpanel \
          ../pufferpanel/config.linux.json=/etc/pufferpanel/config.json
          
          mv *.deb build/
          
          fpm -s deb -t rpm \
          --name pufferpanel \
          --maintainer <EMAIL> \
          --rpm-user pufferpanel --rpm-group pufferpanel \
          --before-install ../pufferpanel/systemd/scripts/preinstall.sh \
          --after-install ../pufferpanel/systemd/scripts/postinstall.sh \
          --after-upgrade ../pufferpanel/systemd/scripts/postupgrade.sh \
          --before-remove ../pufferpanel/systemd/scripts/prerm.sh \
          --after-remove ../pufferpanel/systemd/scripts/postremove.sh \
          build/pufferpanel_*_amd64.deb

          mv *.rpm build/
          
          fpm -s dir -t deb \
          --name pufferpanel -v ${{ env.VERSION }} \
          --maintainer <EMAIL> \
          --deb-user pufferpanel --deb-group pufferpanel \
          --deb-systemd ../pufferpanel/systemd/servicefiles/pufferpanel.service \
          --before-install ../pufferpanel/systemd/scripts/preinstall.sh \
          --after-install ../pufferpanel/systemd/scripts/postinstall.sh \
          --after-upgrade ../pufferpanel/systemd/scripts/postupgrade.sh \
          --before-remove ../pufferpanel/systemd/scripts/prerm.sh \
          --after-remove ../pufferpanel/systemd/scripts/postremove.sh \
          --deb-after-purge ../pufferpanel/systemd/scripts/purge.sh \
          -a armhf \
          binaries/arm/pufferpanel=/usr/sbin/pufferpanel \
          www/pufferpanel=/var/www \
          var/log/pufferpanel=/var/log \
          var/lib/pufferpanel=/var/lib \
          ../pufferpanel/assets/email=/etc/pufferpanel/email \
          ../pufferpanel/config.linux.json=/etc/pufferpanel/config.json
          
          mv *.deb build/
          
{'fraction_non_alphanumeric': 0.1268799764081392, 'fraction_numerical': 0.007814803892657034, 'mean_word_length': 1.666601140161195, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '211774', 'n_tokens_mistral': 4451, 'n_tokens_neox': 4147, 'n_words': 851}