diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index ffd072a..7cba8d3 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -3,12 +3,14 @@ name: tox on: create: # is used for publishing to PyPI and TestPyPI tags: # any tag regardless of its name, no branches + - "**" push: # only publishes pushes to the main branch to TestPyPI branches: # any integration branch but not tag - "master" - tags-ignore: - - "**" pull_request: + release: + types: + - published # It seems that you can publish directly without creating schedule: - cron: 1 0 * * * # Run daily at 0:01 UTC @@ -66,69 +68,74 @@ jobs: echo "${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}" ${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }} - # publish: - # name: Publish to PyPI registry - # needs: - # - build - # runs-on: ubuntu-latest + publish: + name: Publish to PyPI registry + needs: + - build + runs-on: ubuntu-latest - # env: - # PY_COLORS: 1 - # TOXENV: packaging + env: + PY_COLORS: 1 + TOXENV: packaging - # steps: - # - name: Switch to using Python 3.6 by default - # uses: actions/setup-python@v2 - # with: - # python-version: 3.6 - # - name: Install tox - # run: python -m pip install --user tox - # - name: Check out src from Git - # uses: actions/checkout@v2 - # with: - # # Get shallow Git history (default) for tag creation events - # # but have a complete clone for any other workflows. - # # Both options fetch tags but since we're going to remove - # # one from HEAD in non-create-tag workflows, we need full - # # history for them. - # fetch-depth: >- - # ${{ - # ( - # github.event_name == 'create' && - # github.event.ref_type == 'tag' - # ) && - # 1 || 0 - # }} - # - name: Drop Git tags from HEAD for non-tag-create events - # if: >- - # github.event_name != 'create' || - # github.event.ref_type != 'tag' - # run: >- - # git tag --points-at HEAD - # | - # xargs git tag --delete - # - name: Build dists - # run: python -m tox - # - name: Publish to test.pypi.org - # if: >- - # ( - # github.event_name == 'push' && - # github.ref == format( - # 'refs/heads/{0}', github.event.repository.default_branch - # ) - # ) || - # ( - # github.event_name == 'create' && - # github.event.ref_type == 'tag' - # ) - # uses: pypa/gh-action-pypi-publish@master - # with: - # password: ${{ secrets.testpypi_password }} - # repository_url: https://test.pypi.org/legacy/ - # - name: Publish to pypi.org - # if: >- # "create" workflows run separately from "push" & "pull_request" - # github.event_name == 'create' && - # github.event.ref_type == 'tag' - # uses: pypa/gh-action-pypi-publish@master - # with: - # password: ${{ secrets.pypi_password }} + steps: + - name: Switch to using Python 3.6 by default + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install tox + run: python -m pip install --user tox + - name: Check out src from Git + uses: actions/checkout@v2 + with: + # Get shallow Git history (default) for release events + # but have a complete clone for any other workflows. + # Both options fetch tags but since we're going to remove + # one from HEAD in non-create-tag workflows, we need full + # history for them. + fetch-depth: >- + ${{ + ( + ( + github.event_name == 'create' && + github.event.ref_type == 'tag' + ) || + github.event_name == 'release' + ) && + 1 || 0 + }} + - name: Drop Git tags from HEAD for non-tag-create and non-release events + if: >- + ( + github.event_name != 'create' || + github.event.ref_type != 'tag' + ) && + github.event_name != 'release' + run: >- + git tag --points-at HEAD + | + xargs git tag --delete + - name: Build dists + run: python -m tox + - name: Publish to test.pypi.org + if: >- + ( + github.event_name == 'push' && + github.ref == format( + 'refs/heads/{0}', github.event.repository.default_branch + ) + ) || + ( + github.event_name == 'create' && + github.event.ref_type == 'tag' + ) + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.testpypi_password }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish to pypi.org + if: >- # "create" workflows run separately from "push" & "pull_request" + github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_password }}