Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ on:
default: ''
type: string
upload_to_pypi:
description: Always upload to PyPI after successful builds - if false, only upload when pushing tags
description: A condition specifying whether to upload to PyPI
required: false
default: false
type: boolean
default: 'refs/tags/v'
type: string
repository_url:
description: The PyPI repository URL to use
required: false
Expand All @@ -58,6 +58,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-outputs.outputs.matrix }}
upload_to_pypi: ${{ steps.set-upload.outputs.upload_to_pypi }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -69,6 +70,17 @@ jobs:
- id: set-outputs
run: python tools/load_build_targets.py --targets "${{ inputs.targets }}"
shell: sh
- id: set-upload
run: |
if [ $UPLOAD_TO_PYPI == "true" ] || [ $UPLOAD_TAG == "true" ];
then
echo "::set-output name=upload_to_pypi::true"
else
echo "::set-output name=upload_to_pypi::false"
fi
env:
UPLOAD_TO_PYPI: ${{ inputs.upload_to_pypi }}
UPLOAD_TAG: ${{ startsWith(inputs.upload_to_pypi, 'refs/tags/') && github.event_name == 'push' && startsWith(github.event.ref, inputs.upload_to_pypi) }}

build_wheels:
name: Build ${{ matrix.target }} wheels
Expand Down Expand Up @@ -127,11 +139,14 @@ jobs:

upload_pypi:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
needs: [targets, build_wheels, build_sdist]
runs-on: ubuntu-latest
if: |
(( github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')) || inputs.upload_to_pypi ) &&
needs.build_wheels.result != 'failure' && needs.build_sdist.result != 'failure'
always() &&
needs.targets.result == 'success' &&
needs.targets.outputs.upload_to_pypi == 'true' &&
needs.build_wheels.result != 'failure' &&
needs.build_sdist.result != 'failure'
steps:
- uses: actions/download-artifact@v2
with:
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/publish_pure_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ on:
default: ''
type: string
upload_to_pypi:
description: Always upload to PyPI after successful builds - if false, only upload when pushing tags
description: A condition specifying whether to upload to PyPI
required: false
default: false
type: boolean
default: 'refs/tags/v'
type: string
repository_url:
description: The PyPI repository URL to use
required: false
Expand Down Expand Up @@ -59,9 +59,20 @@ jobs:
test_extras: ${{ inputs.test_extras }}
test_command: ${{ inputs.test_command }}
pure_python_wheel: true
- id: set-upload
run: |
if [ $UPLOAD_TO_PYPI == "true" ] || [ $UPLOAD_TAG == "true" ];
then
echo "::set-output name=upload_to_pypi::true"
else
echo "::set-output name=upload_to_pypi::false"
fi
env:
UPLOAD_TO_PYPI: ${{ inputs.upload_to_pypi }}
UPLOAD_TAG: ${{ startsWith(inputs.upload_to_pypi, 'refs/tags/') && github.event_name == 'push' && startsWith(github.event.ref, inputs.upload_to_pypi) }}
- uses: pypa/gh-action-pypi-publish@master
name: Upload to PyPI
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')) || inputs.upload_to_pypi
if: ${{ steps.set-upload.outputs.upload_to_pypi == 'true' }}
with:
user: __token__
password: ${{ secrets.pypi_token }}
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,14 @@ Packages needed to build the source distribution for testing. Must be a string o
Default is install nothing extra.

#### upload_to_pypi
Whether to always upload to PyPI after successful builds.
If `false`, successful builds are only uploaded when tags are pushed.
Default is `false`.
Whether to upload to PyPI after successful builds.
The default is to upload to PyPI when tags that start with `v` are pushed.
A boolean can be passed as `true` (always upload) or `false` (never upload)
either explicitly or as a boolean expression (`${{ <expression> }}`).

Alternatively, a string can be passed to match the start of a tag ref.
For example, `'refs/tags/v'` (default) will upload tags that begin with `v`,
and `'refs/tags/'` will upload on all pushed tags.

#### repository_url
The PyPI repository URL to use.
Expand Down Expand Up @@ -310,9 +315,14 @@ Packages needed to build the source distribution for testing. Must be a string o
Default is install nothing extra.

#### upload_to_pypi
Whether to always upload to PyPI after successful builds.
If `false`, successful builds are only uploaded when tags are pushed.
Default is `false`.
Whether to upload to PyPI after successful builds.
The default is to upload to PyPI when tags that start with `v` are pushed.
A boolean can be passed as `true` (always upload) or `false` (never upload)
either explicitly or as a boolean expression (`${{ <expression> }}`).

Alternatively, a string can be passed to match the start of a tag ref.
For example, `'refs/tags/v'` (default) will upload tags that begin with `v`,
and `'refs/tags/'` will upload on all pushed tags.

#### repository_url
The PyPI repository URL to use.
Expand Down