Skip to content

Commit

Permalink
feat(actions): support PYPI_TOKEN on GitHub Actions
Browse files Browse the repository at this point in the history
Add support for the new PYPI_TOKEN environment variable to be used on GitHub Actions.
  • Loading branch information
danth authored and relekang committed Apr 26, 2020
1 parent a8263a0 commit df2c080
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
1 change: 1 addition & 0 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Copy inputs into correctly-named environment variables
export GH_TOKEN="${INPUT_GITHUB_TOKEN}"
export PYPI_TOKEN="${INPUT_PYPI_TOKEN}"
export PYPI_USERNAME="${INPUT_PYPI_USERNAME}"
export PYPI_PASSWORD="${INPUT_PYPI_PASSWORD}"

Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ inputs:
github_token:
description: 'GitHub token used to push release notes and new commits/tags'
required: true
pypi_token:
description: 'PyPI API token'
pypi_username:
description: 'Username with project access to push to PyPi'
description: 'Username with project access to push to PyPI'
pypi_password:
description: 'Password to the account specified in pypi_username'

Expand Down
45 changes: 19 additions & 26 deletions docs/automatic-releases/github-actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ command.
Inputs
------

+-------------------+-------------------------------------------------+
| Input | Description |
+===================+=================================================+
| ``github_token`` | **Required.** The GitHub token used to post |
| | release notes and push new commits/tags created |
| | by Python Semantic Release. |
+-------------------+-------------------------------------------------+
| ``pypi_username`` | **Required unless upload_to_pypi is false.** |
| | Username with access to push to PyPi. |
+-------------------+-------------------------------------------------+
| ``pypi_password`` | **Required unless upload_to_pypi is false.** |
| | Password to the account specified in |
| | ``pypi_username``. |
+-------------------+-------------------------------------------------+
| ``directory`` | A sub-directory to ``cd`` into before running. |
| | Defaults to the root of the repository. |
+-------------------+-------------------------------------------------+
+--------------------+----------------------------------------------------------------------------------------+
| Input | Description |
+====================+========================================================================================+
| ``github_token`` | See :ref:`env-gh_token`. this is usually set to ``${{ secrets.GITHUB_TOKEN }}``. |
+--------------------+----------------------------------------------------------------------------------------+
| ``pypi_token`` | See :ref:`env-pypi_token`. |
+--------------------+----------------------------------------------------------------------------------------+
| ``pypi_username`` | See :ref:`env-pypi_username`. |
+--------------------+----------------------------------------------------------------------------------------+
| ``pypi_password`` | See :ref:`env-pypi_password`. |
+--------------------+----------------------------------------------------------------------------------------+
| ``directory`` | A sub-directory to ``cd`` into before running. Defaults to the root of the repository. |
+--------------------+----------------------------------------------------------------------------------------+

Other options are taken from your regular configuration file.

Expand Down Expand Up @@ -52,12 +48,11 @@ Example Workflow
uses: relekang/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_username: <ADD YOUR USERNAME HERE>
pypi_password: ${{ secrets.PYPI_PASSWORD }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
``PYPI_PASSWORD`` should be set as a secret on your repository's settings page.
It is safe to include your username directly in the configuration, although you
could also set it as a secret if you wish.
``PYPI_TOKEN`` should be set as a secret on your repository's settings page.
It is also possible to use username and password authentication in a similar
fashion.

.. warning::
You must set `fetch-depth` to 0 when using ``actions/checkout@v2``, since
Expand Down Expand Up @@ -88,16 +83,14 @@ multiple projects.
with:
directory: ./project1
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_username: <ADD YOUR USERNAME HERE>
pypi_password: ${{ secrets.PYPI_PASSWORD }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
- name: Release Project 2
uses: relekang/python-semantic-release@master
with:
directory: ./project2
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_username: <ADD YOUR USERNAME HERE>
pypi_password: ${{ secrets.PYPI_PASSWORD }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
.. note::
The release notes posted to GitHub will not currently distinguish which
Expand Down

0 comments on commit df2c080

Please sign in to comment.