Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Using github actions to publish to PyPi #74

Merged
merged 3 commits into from
Oct 12, 2020
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
49 changes: 1 addition & 48 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,44 +108,6 @@ jobs:
# Must be relative path from root
paths:
- dist-<< parameters.python_version >>

publish-release-pypi:
parameters:
python_version:
default: "2.7"
type: string
executor:
name: container_versions
python_version: <<parameters.python_version>>
working_directory: ~/repo
steps:
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: .

- run:
name: Install twine
command: pip install twine

- run:
name: Create a .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = $PYPI_TOKEN" >> ~/.pypirc
echo -e "[testpypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = $TESTPYPI_TOKEN" >> ~/.pypirc

- run:
name: Upload with twine to Test PyPI
command: twine upload --skip-existing -r testpypi dist-<< parameters.python_version >>/*

- run:
name: Upload with twine to PyPI
command: twine upload -r pypi dist-<< parameters.python_version >>/*



workflows:
version: 2
Expand All @@ -161,19 +123,10 @@ workflows:
- '3.7'
- '3.8'
- '3.9.0rc2'
filters: # required since `publish-release-pypi` has tag filters AND requires `build`
filters:
tags:
only: /.*/
- build
- publish-release-pypi:
requires:
- build-2.7
python_version: "2.7"
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

nightly:
triggers:
Expand Down
4 changes: 2 additions & 2 deletions .github/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name-template: 'Version $NEXT_PATCH_VERSION🌈'
name-template: 'Version $NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '🚀Features'
Expand All @@ -10,7 +10,7 @@ categories:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰Maintenance'
- title: 'Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
exclude-labels:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Pypi
on:
release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 2.7
uses: actions/setup-python@v1
with:
python-version: 2.7

- name: Install twine
run: |
pip install twine

- name: Install wheel
run: |
pip install wheel

- name: Create a source distribution
run: |
python setup.py sdist

- name: Create a wheel
run: |
python setup.py bdist_wheel

- name: Create a .pypirc
run: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
echo -e "[testpypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = ${{ secrets.TESTPYPI_TOKEN }}" >> ~/.pypirc

- name: Publish to Test PyPI
if: github.event_name == 'release'
run: |
twine upload --skip-existing -r testpypi dist/*

- name: Publish to PyPI
if: github.event_name == 'release'
run: |
twine upload -r pypi dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
.idea/

# C extensions
*.so
Expand Down