<commit_before>---
name: Package sch-core
on:
  repository_dispatch:
    types:
    - package-master
    - package-release
  push:
    paths-ignore:
    - doc/**
    - README.md
    - ".github/workflows/build.yml"
    - ".github/workflows/conan.yml"
    - conan/**
    - conanfile.py
    branches:
    - "**"
    tags:
    - v*
jobs:
  check-tag:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
      if: startsWith(github.ref, 'refs/tags/')
    - name: Check version coherency
      run: |
        set -x
        export VERSION=`echo ${{ github.ref }} | sed -e 's@refs/tags/v@@'`
        echo "::set-env name=REJECTION::PROJECT_VERSION in CMakeLists.txt does not match tag"
        grep -q "set(PROJECT_VERSION ${VERSION})" CMakeLists.txt
        echo "::set-env name=REJECTION::Upstream version in debian/changelog does not match tag"
        head -n 1 debian/changelog | grep -q "sch-core (${VERSION}"
        echo "::set-env name=REJECTION::Conan package version does not match tag"
        grep -q "version = \"${VERSION}\"" conanfile.py
        echo "::set-env name=REJECTION::"
        export TAG=`echo ${{ github.ref }} | sed -e 's@refs/tags/@@'`
        echo "::set-env name=RELEASE_TAG::${TAG}"
      if: startsWith(github.ref, 'refs/tags/')
    - name: Delete tag
      run: |
        set -x
        curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X DELETE https://api.github.com/repos/${{ github.repository }}/git/${{ github.ref }}
      if: failure()
    - name: Notify tag deletion
      uses: archive/github-actions-slack@master
      with:
        slack-bot-user-oauth-access-token: "${{ secrets.SLACK_BOT_TOKEN }}"
        slack-channel: "#ci"
        slack-text: |
          Tag *${{ github.ref }}* in *${{ github.repository }}* was deleted:
            ${{ env.REJECTION}}
      if: failure()
    - name: Create release
      uses: jrl-umi3218/github-actions/create-release@master
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        tag: "${{ env.RELEASE_TAG }}"
      if: startsWith(github.ref, 'refs/tags/')
  build-packages:
    needs: check-tag
    strategy:
      fail-fast: false
      matrix:
        dist:
        - xenial
        - bionic
        - focal
        arch:
        - i386
        - amd64
        exclude:
        - dist: focal
          arch: i386
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
    - name: Choose extra mirror
      run: |
        # We upload in all conditions except when building on PR or branch other than master
        export PACKAGE_UPLOAD=true
        if ${{ startsWith(github.ref, 'refs/tags/') }}
        then
          export USE_HEAD=false
        elif [ "${{ github.event.action }}" == "package-master" ]
        then
          export USE_HEAD=true
        elif [ "${{ github.event.action }}" == "package-release" ]
        then
          export USE_HEAD=false
          export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1`
          git checkout $REF
          git submodule sync && git submodule update
        else
          export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'`
          export USE_HEAD=true
          if [ $REF != "master" ]
          then
            export PACKAGE_UPLOAD=false
          fi
        fi
        if $USE_HEAD
        then
          echo "::set-env name=BINTRAY_REPO::multi-contact-head"
          echo "::set-env name=BINTRAY_VERSION::HEAD"
          echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head"
          echo "::set-env name=PACKAGE_JOB::package-master"
        else
          echo "::set-env name=BINTRAY_REPO::multi-contact-release"
          echo "::set-env name=BINTRAY_VERSION::${REF}"
          echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release"
          echo "::set-env name=PACKAGE_JOB::package-release"
        fi
        echo "::set-env name=PACKAGE_UPLOAD::${PACKAGE_UPLOAD}"
    - name: Build package
      uses: jrl-umi3218/github-actions/build-package-native@master
      with:
        dist: "${{ matrix.dist }}"
        arch: "${{ matrix.arch }}"
        other-mirrors: "${{ env.EXTRA_MIRROR }}"
        other-gpg-keys: '0x892EA6EE273707C6495A6FB6220D644C64666806'
    - uses: actions/upload-artifact@v1
      with:
        name: packages-${{ matrix.dist }}-${{ matrix.arch }}
        path: "/tmp/packages-${{ matrix.dist }}-${{ matrix.arch }}/"
      if: env.PACKAGE_UPLOAD == 'true'
  upload-packages:
    needs: build-packages
    strategy:
      max-parallel: 1
      fail-fast: false
      matrix:
        dist:
        - xenial
        - bionic
        - focal
        arch:
        - i386
        - amd64
        exclude:
        - dist: focal
          arch: i386
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
    - name: Choose extra mirror
      run: |
        # We upload in all conditions except when building on PR or branch other than master
        export PACKAGE_UPLOAD=true
        if ${{ startsWith(github.ref, 'refs/tags/') }}
        then
          export USE_HEAD=false
        elif [ "${{ github.event.action }}" == "package-master" ]
        then
          export USE_HEAD=true
        elif [ "${{ github.event.action }}" == "package-release" ]
        then
          export USE_HEAD=false
          export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1`
          git checkout $REF
          git submodule sync && git submodule update
        else
          export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'`<commit_msg>[ci] Only upload packages on official remote<commit_after>---
name: Package sch-core
on:
  repository_dispatch:
    types:
    - package-master
    - package-release
  push:
    paths-ignore:
    - doc/**
    - README.md
    - ".github/workflows/build.yml"
    - ".github/workflows/conan.yml"
    - conan/**
    - conanfile.py
    branches:
    - "**"
    tags:
    - v*
jobs:
  check-tag:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
      if: startsWith(github.ref, 'refs/tags/')
    - name: Check version coherency
      run: |
        set -x
        export VERSION=`echo ${{ github.ref }} | sed -e 's@refs/tags/v@@'`
        echo "::set-env name=REJECTION::PROJECT_VERSION in CMakeLists.txt does not match tag"
        grep -q "set(PROJECT_VERSION ${VERSION})" CMakeLists.txt
        echo "::set-env name=REJECTION::Upstream version in debian/changelog does not match tag"
        head -n 1 debian/changelog | grep -q "sch-core (${VERSION}"
        echo "::set-env name=REJECTION::Conan package version does not match tag"
        grep -q "version = \"${VERSION}\"" conanfile.py
        echo "::set-env name=REJECTION::"
        export TAG=`echo ${{ github.ref }} | sed -e 's@refs/tags/@@'`
        echo "::set-env name=RELEASE_TAG::${TAG}"
      if: startsWith(github.ref, 'refs/tags/')
    - name: Delete tag
      run: |
        set -x
        curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X DELETE https://api.github.com/repos/${{ github.repository }}/git/${{ github.ref }}
      if: failure()
    - name: Notify tag deletion
      uses: archive/github-actions-slack@master
      with:
        slack-bot-user-oauth-access-token: "${{ secrets.SLACK_BOT_TOKEN }}"
        slack-channel: "#ci"
        slack-text: |
          Tag *${{ github.ref }}* in *${{ github.repository }}* was deleted:
            ${{ env.REJECTION}}
      if: failure()
    - name: Create release
      uses: jrl-umi3218/github-actions/create-release@master
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        tag: "${{ env.RELEASE_TAG }}"
      if: startsWith(github.ref, 'refs/tags/')
  build-packages:
    needs: check-tag
    strategy:
      fail-fast: false
      matrix:
        dist:
        - xenial
        - bionic
        - focal
        arch:
        - i386
        - amd64
        exclude:
        - dist: focal
          arch: i386
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
    - name: Choose extra mirror
      run: |
        # We upload in all conditions except when building on PR or branch other than master
        export PACKAGE_UPLOAD=true
        if ${{ startsWith(github.ref, 'refs/tags/') }}
        then
          export USE_HEAD=false
        elif [ "${{ github.event.action }}" == "package-master" ]
        then
          export USE_HEAD=true
        elif [ "${{ github.event.action }}" == "package-release" ]
        then
          export USE_HEAD=false
          export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1`
          git checkout $REF
          git submodule sync && git submodule update
        else
          export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'`
          export USE_HEAD=true
          if [ $REF != "master" ]
          then
            export PACKAGE_UPLOAD=false
          fi
        fi
        if $USE_HEAD
        then
          echo "::set-env name=BINTRAY_REPO::multi-contact-head"
          echo "::set-env name=BINTRAY_VERSION::HEAD"
          echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head"
          echo "::set-env name=PACKAGE_JOB::package-master"
        else
          echo "::set-env name=BINTRAY_REPO::multi-contact-release"
          echo "::set-env name=BINTRAY_VERSION::${REF}"
          echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release"
          echo "::set-env name=PACKAGE_JOB::package-release"
        fi
        echo "::set-env name=PACKAGE_UPLOAD::${PACKAGE_UPLOAD}"
    - name: Build package
      uses: jrl-umi3218/github-actions/build-package-native@master
      with:
        dist: "${{ matrix.dist }}"
        arch: "${{ matrix.arch }}"
        other-mirrors: "${{ env.EXTRA_MIRROR }}"
        other-gpg-keys: '0x892EA6EE273707C6495A6FB6220D644C64666806'
    - uses: actions/upload-artifact@v1
      with:
        name: packages-${{ matrix.dist }}-${{ matrix.arch }}
        path: "/tmp/packages-${{ matrix.dist }}-${{ matrix.arch }}/"
      if: env.PACKAGE_UPLOAD == 'true'
  upload-packages:
    needs: build-packages
    strategy:
      max-parallel: 1
      fail-fast: false
      matrix:
        dist:
        - xenial
        - bionic
        - focal
        arch:
        - i386
        - amd64
        exclude:
        - dist: focal
          arch: i386
    runs-on: ubuntu-18.04
    if: github.ref == 'refs/heads/master' && github.repository == 'jrl-umi3218/sch-core'
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
    - name: Choose extra mirror
      run: |
        # We upload in all conditions except when building on PR or branch other than master
        export PACKAGE_UPLOAD=true
        if ${{ startsWith(github.ref, 'refs/tags/') }}
        then
          export USE_HEAD=false
        elif [ "${{ github.event.action }}" == "package-master" ]
        then
          export USE_HEAD=true
        elif [ "${{ github.event.action }}" == "package-release" ]
        then
          export USE_HEAD=false
          export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1`
          git checkout $REF
          git submodule sync && git submodule update
        else
          export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'`
{'fraction_non_alphanumeric': 0.13846685082872928, 'fraction_numerical': 0.013984806629834255, 'mean_word_length': 1.9873646209386282, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '7293351', 'n_tokens_mistral': 3944, 'n_tokens_neox': 3749, 'n_words': 834}