name: release

on:
  release:
    types:
      - created

jobs:
  release-job:
    runs-on: ubuntu-latest
    env:
      PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Install release tooling
      run: |
        pip install twine wheel
    - name: Build package
      run: |
        python setup.py sdist bdist_wheel
    - name: Check version number match
      run: |
        echo "GITHUB_REF: ${GITHUB_REF}"
        # The GITHUB_REF should be something like "refs/tags/v3.x.x"
        # Make sure the package version is the same as the tag
        grep -Rq "^Version: ${GITHUB_REF:10}$" blackjax.egg-info/PKG-INFO
    - name: Publish to PyPI
      run: |
        twine check dist/*
        twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/*
  test-install-job:
    needs: release-job
    runs-on: ubuntu-latest
    steps:
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Give PyPI some time to update the index
      run: sleep 240
    - name: Install from PyPI
      run: |
        pip install blackjax==${GITHUB_REF:11}

name: release

on:
  release:
    types:
      - created

jobs:
  release-job:
    runs-on: ubuntu-latest
    env:
      PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Install release tooling
      run: |
        pip install twine wheel
    - name: Build package
      run: |
        python setup.py sdist bdist_wheel
    - name: Check version number match
      run: |
        echo "GITHUB_REF: ${GITHUB_REF}"
        # The GITHUB_REF should be something like "refs/tags/v3.x.x"
        # Make sure the package version is the same as the tag
        grep -Rq "^Version: ${GITHUB_REF:10}$" blackjax.egg-info/PKG-INFO
    - name: Publish to PyPI
      run: |
        twine check dist/*
        twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/*
  test-install-job:
    needs: release-job
    runs-on: ubuntu-latest
    steps:
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Give PyPI some time to update the index
      run: sleep 240
    - name: Install from PyPI
      run: |
        pip install blackjax==${GITHUB_REF:10}

Truncate GITHUB_REF at the right level
Truncate GITHUB_REF at the right level

The workflow that checks that blackjax can be installed from PyPi
currently fails because `$GITHUB_REF` is truncated before the leading
version number (currently 0). This commit fixes this.
