From e880724755b729fc0dfa93c3b625603a853460ad Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Sun, 15 Sep 2019 22:48:28 +0200 Subject: [PATCH 01/17] Add a guide about publishing dists via GH Actions Resolves pypa/gh-action-pypi-publish#2 --- source/guides/index.rst | 1 + ...s-using-github-actions-ci-cd-workflows.rst | 168 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst diff --git a/source/guides/index.rst b/source/guides/index.rst index b8d25d499e..9b4f89fb60 100644 --- a/source/guides/index.rst +++ b/source/guides/index.rst @@ -29,3 +29,4 @@ introduction to packaging, see :doc:`/tutorials/index`. migrating-to-pypi-org using-testpypi making-a-pypi-friendly-readme + publishing-package-distribution-releases-using-github-actions-ci-cd-workflows diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst new file mode 100644 index 0000000000..c2221a8ea5 --- /dev/null +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -0,0 +1,168 @@ +Publishing Package Distribution 📦 Releases Using GitHub Actions CI/CD Workflows 🤖 +=================================================================================== + +`GitHub Actions CI/CD`_ allow you to run a series of commands +whenever an event occurs in the GitHub Platform. One of the +popular choices is having a workflow that's triggered by a +``push`` event. +This guide will show you how to publish a Python distribution +package whenever a tagged commit is pushed. + +.. attention:: + + This guide *assumes* that you already have a project that + you know how to build dists for and *it lives on GitHub*. + +.. warning:: + + At the time of writing this guide, `GitHub Actions CI/CD`_ + is still in public beta. If you don't have it enabled, + you should join the waitlist in order to gain the access. + + N.B. It is known that GitHub is going to make Actions + publicly available on the Nov 13th, 2019. + + +Saving credentials on GitHub +---------------------------- + +In this guide, we'll demonstrate uploading to both production +PyPI and Test PyPI meaning that we'll have two separate sets +of creds. And we'll need to save them in GitHub repo settings. + +Let's begin! 🚀 + +1. Go to https://pypi.org/manage/account/#api-tokens and + create a new `API token`_. If you have the project on PyPI + already, please limit the token scope to just that project. + You can call it smth like + ``GitHub Actions CI/CD — project-org/project-repo`` + in order for it to be easily distinguishable in the token + list. + **Don't close the page just yet — you won't see that token + again.** +2. In a separate browser tab or window, go to the ``Settings`` + tab of your target repository and then click on `Secrets`_ + in the left sidebar. +3. Create a new secret called ``pypi_password`` and copy-paste + the token from the fist step. +4. Now, go to https://test.pypi.org/manage/account/#api-tokens + and repeat the steps. Save that Test PyPI token on GitHub + as ``test_pypi_password``. + + +Creating a workflow definition +------------------------------ + +GitHub CI/CD Workflows are declared in YAML files stored under +``.github/`` of your repository. + +Start it with a meaningful name and define the even that +should make GitHub run this workflow: + +.. code-block:: yaml + + name: Publish Python 🐛 distribution package 📦 to PyPIs + + on: push + + +Defining a workflow job environment +----------------------------------- + +Now, let's add initial setup for our job. It's a process that +will execute commands that we'll define later. +In this guide, we'll choose to use Ubuntu 18.04: + +.. code-block:: yaml + + build-n-publish: + name: Build and publish Python 🐛 dist 📦 to PyPIs + runs-on: ubuntu-18.04 + + +Checking out the project and building dists +------------------------------------------- + +Then, add the following under the ``build-n-publish`` section: + +.. code-block:: yaml + + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + version: 3.7 + +This will download your repository into the CI runner and then +install and activate Python 3.7. + +And now we can build dists from source. In this example, we'll +use ``pep517`` package, *assuming that your project has a ``pyproject.toml`` properly set up (see :pep:`517`/:pep:`518`)*. + +.. tip:: + + You can use any other method for building dists as long as + it produces ready-to-upload artifacts saved into ``dist/`` + folder. + +So add this to the steps list: + +.. code-block:: yaml + + - name: Install pep517 + run: >- + python -m + pip install + pep517 + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + pep517.build + --source + --binary + --out-dir dist/ + . + + +Publishing dist to Test PyPI and production PyPI +------------------------------------------------ + +Finally, add the following steps in the end: + +.. code-block:: yaml + + - name: Publish 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.test_pypi_password }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish 📦 to production PyPI + if: startsWith(github.event.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_password }} + +These two steps use `pypa/gh-action-pypi-publish`_ GitHub +Action: the first one uploads contents of the `dist/` folder +into Test PyPI unconditionally and the second does that to +production PyPI but only if the current commit is tagged. + + +That's all, folks! +------------------ + +Now, whenever you push a tagged commit to your Git repo remote +on GitHub, this workflow will publish it to PyPI. +And it'll publish any push to Test PyPI which is useful for +providing test builds to your alpha users as well as making +sure that your release pipeline keeps being healthy! + + +.. _API token: https://pypi.org/help/#apitoken +.. _GitHub Actions CI/CD: https://github.com/features/actions +.. _pypa/gh-action-pypi-publish: +.. _Secrets: + https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables From 3fc324468725db414fefd53e8d58c1dc26a4fa0d Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 23:47:36 +0300 Subject: [PATCH 02/17] Apply style corrections Co-Authored-By: Hugo van Kemenade --- ...s-using-github-actions-ci-cd-workflows.rst | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index c2221a8ea5..75c9223886 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -1,11 +1,11 @@ -Publishing Package Distribution 📦 Releases Using GitHub Actions CI/CD Workflows 🤖 +Publishing package distribution 📦 releases using GitHub Actions CI/CD workflows 🤖 =================================================================================== `GitHub Actions CI/CD`_ allow you to run a series of commands -whenever an event occurs in the GitHub Platform. One of the -popular choices is having a workflow that's triggered by a +whenever an event occurs on the GitHub platform. One +popular choice is having a workflow that's triggered by a ``push`` event. -This guide will show you how to publish a Python distribution +This guide shows you how to publish a Python distribution package whenever a tagged commit is pushed. .. attention:: @@ -15,12 +15,11 @@ package whenever a tagged commit is pushed. .. warning:: - At the time of writing this guide, `GitHub Actions CI/CD`_ - is still in public beta. If you don't have it enabled, - you should join the waitlist in order to gain the access. + At the time of writing, `GitHub Actions CI/CD`_ + is in public beta. If you don't have it enabled, + you should join the waitlist to gain access. - N.B. It is known that GitHub is going to make Actions - publicly available on the Nov 13th, 2019. + GitHub Actions will be generally available on November 13th, 2019. Saving credentials on GitHub @@ -28,14 +27,14 @@ Saving credentials on GitHub In this guide, we'll demonstrate uploading to both production PyPI and Test PyPI meaning that we'll have two separate sets -of creds. And we'll need to save them in GitHub repo settings. +of creds. And we'll need to save them in the GitHub repo settings. Let's begin! 🚀 1. Go to https://pypi.org/manage/account/#api-tokens and create a new `API token`_. If you have the project on PyPI - already, please limit the token scope to just that project. - You can call it smth like + already, limit the token scope to just that project. + You can call it something like ``GitHub Actions CI/CD — project-org/project-repo`` in order for it to be easily distinguishable in the token list. @@ -54,15 +53,15 @@ Let's begin! 🚀 Creating a workflow definition ------------------------------ -GitHub CI/CD Workflows are declared in YAML files stored under -``.github/`` of your repository. +GitHub CI/CD workflows are declared in YAML files stored under +``.github/workflows/`` of your repository. -Start it with a meaningful name and define the even that +Start it with a meaningful name and define the event that should make GitHub run this workflow: .. code-block:: yaml - name: Publish Python 🐛 distribution package 📦 to PyPIs + name: Publish Python 🐍 distribution package 📦 to PyPIs on: push @@ -104,7 +103,7 @@ use ``pep517`` package, *assuming that your project has a ``pyproject.toml`` pro .. tip:: You can use any other method for building dists as long as - it produces ready-to-upload artifacts saved into ``dist/`` + it produces ready-to-upload artifacts saved into the ``dist/`` folder. So add this to the steps list: @@ -130,7 +129,7 @@ So add this to the steps list: Publishing dist to Test PyPI and production PyPI ------------------------------------------------ -Finally, add the following steps in the end: +Finally, add the following steps at the end: .. code-block:: yaml @@ -145,8 +144,8 @@ Finally, add the following steps in the end: with: password: ${{ secrets.pypi_password }} -These two steps use `pypa/gh-action-pypi-publish`_ GitHub -Action: the first one uploads contents of the `dist/` folder +These two steps use the `pypa/gh-action-pypi-publish`_ GitHub +Action: the first one uploads contents of the ``dist/`` folder into Test PyPI unconditionally and the second does that to production PyPI but only if the current commit is tagged. @@ -158,7 +157,7 @@ Now, whenever you push a tagged commit to your Git repo remote on GitHub, this workflow will publish it to PyPI. And it'll publish any push to Test PyPI which is useful for providing test builds to your alpha users as well as making -sure that your release pipeline keeps being healthy! +sure that your release pipeline remains healthy! .. _API token: https://pypi.org/help/#apitoken From 0b3ff397ddc8a0a80e20e9d5beff3c094ea09660 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 22:51:14 +0200 Subject: [PATCH 03/17] Drop emojis from the guide title --- ...ribution-releases-using-github-actions-ci-cd-workflows.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 75c9223886..49d86bc0f0 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -1,5 +1,5 @@ -Publishing package distribution 📦 releases using GitHub Actions CI/CD workflows 🤖 -=================================================================================== +Publishing package distribution releases using GitHub Actions CI/CD workflows +============================================================================= `GitHub Actions CI/CD`_ allow you to run a series of commands whenever an event occurs on the GitHub platform. One From a625acfef1662789e759c13a93182e573a6f6f6e Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 22:54:19 +0200 Subject: [PATCH 04/17] Align guide titles' styles --- ...eleases-using-github-actions-ci-cd-workflows.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 49d86bc0f0..7951c03028 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -1,3 +1,4 @@ +============================================================================= Publishing package distribution releases using GitHub Actions CI/CD workflows ============================================================================= @@ -23,7 +24,7 @@ package whenever a tagged commit is pushed. Saving credentials on GitHub ----------------------------- +============================ In this guide, we'll demonstrate uploading to both production PyPI and Test PyPI meaning that we'll have two separate sets @@ -51,7 +52,7 @@ Let's begin! 🚀 Creating a workflow definition ------------------------------- +============================== GitHub CI/CD workflows are declared in YAML files stored under ``.github/workflows/`` of your repository. @@ -67,7 +68,7 @@ should make GitHub run this workflow: Defining a workflow job environment ------------------------------------ +=================================== Now, let's add initial setup for our job. It's a process that will execute commands that we'll define later. @@ -81,7 +82,7 @@ In this guide, we'll choose to use Ubuntu 18.04: Checking out the project and building dists -------------------------------------------- +=========================================== Then, add the following under the ``build-n-publish`` section: @@ -127,7 +128,7 @@ So add this to the steps list: Publishing dist to Test PyPI and production PyPI ------------------------------------------------- +================================================ Finally, add the following steps at the end: @@ -151,7 +152,7 @@ production PyPI but only if the current commit is tagged. That's all, folks! ------------------- +================== Now, whenever you push a tagged commit to your Git repo remote on GitHub, this workflow will publish it to PyPI. From 7a9912f98fec013e6c6722de82f3a924eb9a23d9 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 23:28:35 +0200 Subject: [PATCH 05/17] Store GitHub Actions CI/CD workflow def separately --- .../publish-to-test-pypi.yml | 40 +++++++++++ ...s-using-github-actions-ci-cd-workflows.rst | 66 ++++++------------- 2 files changed, 60 insertions(+), 46 deletions(-) create mode 100644 source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml diff --git a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml new file mode 100644 index 0000000000..d35987af1b --- /dev/null +++ b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml @@ -0,0 +1,40 @@ +name: Publish Python 🐍 distribution package 📦 to PyPIs + +on: push + +jobs: + build-n-publish: + name: Build and publish Python 🐛 dist 📦 to PyPIs + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + version: 3.7 + - name: Install pep517 + run: >- + python -m + pip install + pep517 + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + pep517.build + --source + --binary + --out-dir dist/ + . + # Actualy publish to PyPIs + - name: Publish 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.test_pypi_password }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish 📦 to production PyPI + if: startsWith(github.event.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_password }} diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 7951c03028..1f79d40a20 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -57,14 +57,14 @@ Creating a workflow definition GitHub CI/CD workflows are declared in YAML files stored under ``.github/workflows/`` of your repository. +Let's create ``.github/workflows/publish-to-test-pypi.yml`` file. + Start it with a meaningful name and define the event that should make GitHub run this workflow: -.. code-block:: yaml - - name: Publish Python 🐍 distribution package 📦 to PyPIs - - on: push +.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml + :language: yaml + :end-before: jobs: Defining a workflow job environment @@ -74,11 +74,10 @@ Now, let's add initial setup for our job. It's a process that will execute commands that we'll define later. In this guide, we'll choose to use Ubuntu 18.04: -.. code-block:: yaml - - build-n-publish: - name: Build and publish Python 🐛 dist 📦 to PyPIs - runs-on: ubuntu-18.04 +.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml + :language: yaml + :start-after: on: + :end-before: steps: Checking out the project and building dists @@ -86,14 +85,10 @@ Checking out the project and building dists Then, add the following under the ``build-n-publish`` section: -.. code-block:: yaml - - steps: - - uses: actions/checkout@master - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - version: 3.7 +.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml + :language: yaml + :start-after: runs-on: + :end-before: Install pep517 This will download your repository into the CI runner and then install and activate Python 3.7. @@ -109,22 +104,10 @@ use ``pep517`` package, *assuming that your project has a ``pyproject.toml`` pro So add this to the steps list: -.. code-block:: yaml - - - name: Install pep517 - run: >- - python -m - pip install - pep517 - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - pep517.build - --source - --binary - --out-dir dist/ - . +.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml + :language: yaml + :start-after: version: 3.7 + :end-before: Actualy publish to PyPIs Publishing dist to Test PyPI and production PyPI @@ -132,18 +115,9 @@ Publishing dist to Test PyPI and production PyPI Finally, add the following steps at the end: -.. code-block:: yaml - - - name: Publish 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.test_pypi_password }} - repository_url: https://test.pypi.org/legacy/ - - name: Publish 📦 to production PyPI - if: startsWith(github.event.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.pypi_password }} +.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml + :language: yaml + :start-after: Actualy publish to PyPIs These two steps use the `pypa/gh-action-pypi-publish`_ GitHub Action: the first one uploads contents of the ``dist/`` folder From d3a7e8dceaf796e9f8eb76afebb0c853e7dddd26 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 23:29:52 +0200 Subject: [PATCH 06/17] Un-highlight the assumption --- ...stribution-releases-using-github-actions-ci-cd-workflows.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 1f79d40a20..1a3b98976c 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -94,7 +94,7 @@ This will download your repository into the CI runner and then install and activate Python 3.7. And now we can build dists from source. In this example, we'll -use ``pep517`` package, *assuming that your project has a ``pyproject.toml`` properly set up (see :pep:`517`/:pep:`518`)*. +use ``pep517`` package, assuming that your project has a ``pyproject.toml`` properly set up (see :pep:`517`/:pep:`518`). .. tip:: From 819c527684e9c822322406dce8cdc3c82a96a509 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 23:37:29 +0200 Subject: [PATCH 07/17] Wrap lines better in RST --- ...ses-using-github-actions-ci-cd-workflows.rst | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 1a3b98976c..93c73e454b 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -20,7 +20,8 @@ package whenever a tagged commit is pushed. is in public beta. If you don't have it enabled, you should join the waitlist to gain access. - GitHub Actions will be generally available on November 13th, 2019. + GitHub Actions will be generally available on November + 13th, 2019. Saving credentials on GitHub @@ -28,7 +29,8 @@ Saving credentials on GitHub In this guide, we'll demonstrate uploading to both production PyPI and Test PyPI meaning that we'll have two separate sets -of creds. And we'll need to save them in the GitHub repo settings. +of creds. And we'll need to save them in the GitHub repo +settings. Let's begin! 🚀 @@ -57,7 +59,8 @@ Creating a workflow definition GitHub CI/CD workflows are declared in YAML files stored under ``.github/workflows/`` of your repository. -Let's create ``.github/workflows/publish-to-test-pypi.yml`` file. +Let's create ``.github/workflows/publish-to-test-pypi.yml`` +file. Start it with a meaningful name and define the event that should make GitHub run this workflow: @@ -94,13 +97,15 @@ This will download your repository into the CI runner and then install and activate Python 3.7. And now we can build dists from source. In this example, we'll -use ``pep517`` package, assuming that your project has a ``pyproject.toml`` properly set up (see :pep:`517`/:pep:`518`). +use ``pep517`` package, assuming that your project has a +``pyproject.toml`` properly set up (see +:pep:`517`/:pep:`518`). .. tip:: You can use any other method for building dists as long as - it produces ready-to-upload artifacts saved into the ``dist/`` - folder. + it produces ready-to-upload artifacts saved into the + ``dist/`` folder. So add this to the steps list: From 1e8ba4869bfeb16ab800534403ad6338ab98cdb4 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 23:39:16 +0200 Subject: [PATCH 08/17] Add a waitlist link --- ...tribution-releases-using-github-actions-ci-cd-workflows.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 93c73e454b..86ff220ea2 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -18,7 +18,7 @@ package whenever a tagged commit is pushed. At the time of writing, `GitHub Actions CI/CD`_ is in public beta. If you don't have it enabled, - you should join the waitlist to gain access. + you should `join the waitlist`_ to gain access. GitHub Actions will be generally available on November 13th, 2019. @@ -142,6 +142,7 @@ sure that your release pipeline remains healthy! .. _API token: https://pypi.org/help/#apitoken .. _GitHub Actions CI/CD: https://github.com/features/actions +.. _join the waitlist: https://github.com/features/actions/signup .. _pypa/gh-action-pypi-publish: .. _Secrets: https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables From b746ce23c9d9a2e7536c729d145bf5b1ac64e6e5 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 16 Sep 2019 23:41:13 +0200 Subject: [PATCH 09/17] Fix a bug/snake emoji in the GH workflow sample --- .../guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml index d35987af1b..09d623597a 100644 --- a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml +++ b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml @@ -4,7 +4,7 @@ on: push jobs: build-n-publish: - name: Build and publish Python 🐛 dist 📦 to PyPIs + name: Build and publish Python 🐍 dist 📦 to PyPIs runs-on: ubuntu-18.04 steps: From 5fa47afb43e0d2741de5ed80d44c47b2f2791dcd Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 18 Sep 2019 12:23:46 +0300 Subject: [PATCH 10/17] Apply style and grammar corrections Co-Authored-By: Hugo van Kemenade --- ...bution-releases-using-github-actions-ci-cd-workflows.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 86ff220ea2..e39574b64e 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -2,7 +2,7 @@ Publishing package distribution releases using GitHub Actions CI/CD workflows ============================================================================= -`GitHub Actions CI/CD`_ allow you to run a series of commands +`GitHub Actions CI/CD`_ allows you to run a series of commands whenever an event occurs on the GitHub platform. One popular choice is having a workflow that's triggered by a ``push`` event. @@ -59,7 +59,7 @@ Creating a workflow definition GitHub CI/CD workflows are declared in YAML files stored under ``.github/workflows/`` of your repository. -Let's create ``.github/workflows/publish-to-test-pypi.yml`` +Let's create a ``.github/workflows/publish-to-test-pypi.yml`` file. Start it with a meaningful name and define the event that @@ -75,7 +75,7 @@ Defining a workflow job environment Now, let's add initial setup for our job. It's a process that will execute commands that we'll define later. -In this guide, we'll choose to use Ubuntu 18.04: +In this guide, we'll use Ubuntu 18.04: .. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml :language: yaml From 9a1564752f9d789e41a75876813c7029c16a3e1e Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 19 Sep 2019 12:38:38 +0300 Subject: [PATCH 11/17] Fix TestPyPI spelling Co-Authored-By: Dustin Ingram --- .../publish-to-test-pypi.yml | 2 +- ...leases-using-github-actions-ci-cd-workflows.rst | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml index 09d623597a..049b57d32b 100644 --- a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml +++ b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml @@ -27,7 +27,7 @@ jobs: --binary --out-dir dist/ . - # Actualy publish to PyPIs + # Actually publish to PyPI/TestPyPI - name: Publish 📦 to Test PyPI uses: pypa/gh-action-pypi-publish@master with: diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index e39574b64e..adbbdd035e 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -28,7 +28,7 @@ Saving credentials on GitHub ============================ In this guide, we'll demonstrate uploading to both production -PyPI and Test PyPI meaning that we'll have two separate sets +PyPI and TestPyPI, meaning that we'll have two separate sets of creds. And we'll need to save them in the GitHub repo settings. @@ -49,7 +49,7 @@ Let's begin! 🚀 3. Create a new secret called ``pypi_password`` and copy-paste the token from the fist step. 4. Now, go to https://test.pypi.org/manage/account/#api-tokens - and repeat the steps. Save that Test PyPI token on GitHub + and repeat the steps. Save that TestPyPI token on GitHub as ``test_pypi_password``. @@ -112,21 +112,21 @@ So add this to the steps list: .. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml :language: yaml :start-after: version: 3.7 - :end-before: Actualy publish to PyPIs + :end-before: Actually publish to PyPI/TestPyPI -Publishing dist to Test PyPI and production PyPI +Publishing the distribution to PyPI and TestPyPI ================================================ Finally, add the following steps at the end: .. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml :language: yaml - :start-after: Actualy publish to PyPIs + :start-after: Actually publish to PyPI/TestPyPI These two steps use the `pypa/gh-action-pypi-publish`_ GitHub Action: the first one uploads contents of the ``dist/`` folder -into Test PyPI unconditionally and the second does that to +into TestPyPI unconditionally and the second does that to production PyPI but only if the current commit is tagged. @@ -135,7 +135,7 @@ That's all, folks! Now, whenever you push a tagged commit to your Git repo remote on GitHub, this workflow will publish it to PyPI. -And it'll publish any push to Test PyPI which is useful for +And it'll publish any push to TestPyPI which is useful for providing test builds to your alpha users as well as making sure that your release pipeline remains healthy! From bdcc96870bc002fda47bcbf4105f7f5a9d5eb495 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 19 Sep 2019 15:52:21 +0300 Subject: [PATCH 12/17] Use long versions of words in the guide Co-Authored-By: Dustin Ingram --- .../publish-to-test-pypi.yml | 8 ++++---- ...releases-using-github-actions-ci-cd-workflows.rst | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml index 049b57d32b..a2930a0b74 100644 --- a/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml +++ b/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml @@ -1,10 +1,10 @@ -name: Publish Python 🐍 distribution package 📦 to PyPIs +name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI on: push jobs: build-n-publish: - name: Build and publish Python 🐍 dist 📦 to PyPIs + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI runs-on: ubuntu-18.04 steps: @@ -28,12 +28,12 @@ jobs: --out-dir dist/ . # Actually publish to PyPI/TestPyPI - - name: Publish 📦 to Test PyPI + - name: Publish distribution 📦 to Test PyPI uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.test_pypi_password }} repository_url: https://test.pypi.org/legacy/ - - name: Publish 📦 to production PyPI + - name: Publish distribution 📦 to PyPI if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master with: diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index adbbdd035e..1f98a2a38d 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -12,7 +12,7 @@ package whenever a tagged commit is pushed. .. attention:: This guide *assumes* that you already have a project that - you know how to build dists for and *it lives on GitHub*. + you know how to build distributions for and *it lives on GitHub*. .. warning:: @@ -29,7 +29,7 @@ Saving credentials on GitHub In this guide, we'll demonstrate uploading to both production PyPI and TestPyPI, meaning that we'll have two separate sets -of creds. And we'll need to save them in the GitHub repo +of credentials. And we'll need to save them in the GitHub repository settings. Let's begin! 🚀 @@ -83,8 +83,8 @@ In this guide, we'll use Ubuntu 18.04: :end-before: steps: -Checking out the project and building dists -=========================================== +Checking out the project and building distributions +=================================================== Then, add the following under the ``build-n-publish`` section: @@ -103,7 +103,7 @@ use ``pep517`` package, assuming that your project has a .. tip:: - You can use any other method for building dists as long as + You can use any other method for building distributions as long as it produces ready-to-upload artifacts saved into the ``dist/`` folder. @@ -133,7 +133,7 @@ production PyPI but only if the current commit is tagged. That's all, folks! ================== -Now, whenever you push a tagged commit to your Git repo remote +Now, whenever you push a tagged commit to your Git repository remote on GitHub, this workflow will publish it to PyPI. And it'll publish any push to TestPyPI which is useful for providing test builds to your alpha users as well as making From 4b1e6d2d97d5f3548f34f5884e9112add51be1b2 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 19 Sep 2019 15:53:52 +0300 Subject: [PATCH 13/17] Apply style fixes from code review Co-Authored-By: Dustin Ingram --- ...n-releases-using-github-actions-ci-cd-workflows.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 1f98a2a38d..e558f18a8c 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -7,7 +7,7 @@ whenever an event occurs on the GitHub platform. One popular choice is having a workflow that's triggered by a ``push`` event. This guide shows you how to publish a Python distribution -package whenever a tagged commit is pushed. +whenever a tagged commit is pushed. .. attention:: @@ -27,7 +27,7 @@ package whenever a tagged commit is pushed. Saving credentials on GitHub ============================ -In this guide, we'll demonstrate uploading to both production +In this guide, we'll demonstrate uploading to both PyPI and TestPyPI, meaning that we'll have two separate sets of credentials. And we'll need to save them in the GitHub repository settings. @@ -56,8 +56,8 @@ Let's begin! 🚀 Creating a workflow definition ============================== -GitHub CI/CD workflows are declared in YAML files stored under -``.github/workflows/`` of your repository. +GitHub CI/CD workflows are declared in YAML files stored in the +``.github/workflows/`` directory of your repository. Let's create a ``.github/workflows/publish-to-test-pypi.yml`` file. @@ -127,7 +127,7 @@ Finally, add the following steps at the end: These two steps use the `pypa/gh-action-pypi-publish`_ GitHub Action: the first one uploads contents of the ``dist/`` folder into TestPyPI unconditionally and the second does that to -production PyPI but only if the current commit is tagged. +PyPI, but only if the current commit is tagged. That's all, folks! From db67d033b09962b9e4a7536d7fe199eb35939870 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 19 Sep 2019 15:57:29 +0200 Subject: [PATCH 14/17] Add a note that PyPI acc != TestPyPI acc --- ...ibution-releases-using-github-actions-ci-cd-workflows.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index e558f18a8c..8ffda34d42 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -52,6 +52,11 @@ Let's begin! 🚀 and repeat the steps. Save that TestPyPI token on GitHub as ``test_pypi_password``. + .. attention:: + + If you don't have a TestPyPI account, you'll need to + create it. It's not the same as a regular PyPI account. + Creating a workflow definition ============================== From 37948f8e886d4e9d5d7f846b24d2e0a940918865 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 19 Sep 2019 15:58:25 +0200 Subject: [PATCH 15/17] Drop a note about GH Actions GA on Nov 13th --- ...tribution-releases-using-github-actions-ci-cd-workflows.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 8ffda34d42..57582492b2 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -20,9 +20,6 @@ whenever a tagged commit is pushed. is in public beta. If you don't have it enabled, you should `join the waitlist`_ to gain access. - GitHub Actions will be generally available on November - 13th, 2019. - Saving credentials on GitHub ============================ From a807576cfa953cac9d845c461aa4729488219fe9 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 26 Sep 2019 01:33:41 +0200 Subject: [PATCH 16/17] Mention GitHub Action Marketplace page --- ...tribution-releases-using-github-actions-ci-cd-workflows.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 57582492b2..7cdc5169d1 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -8,6 +8,7 @@ popular choice is having a workflow that's triggered by a ``push`` event. This guide shows you how to publish a Python distribution whenever a tagged commit is pushed. +It will use the `pypa/gh-action-pypi-publish GitHub Action`_ https://github.com/marketplace/actions/pypi-publish .. attention:: @@ -146,5 +147,7 @@ sure that your release pipeline remains healthy! .. _GitHub Actions CI/CD: https://github.com/features/actions .. _join the waitlist: https://github.com/features/actions/signup .. _pypa/gh-action-pypi-publish: +.. _`pypa/gh-action-pypi-publish GitHub Action`: + https://github.com/marketplace/actions/pypi-publish .. _Secrets: https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables From 0cad2546ab512b0c7819df5dcdf4cf0dfc0fb081 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 26 Sep 2019 01:34:25 +0200 Subject: [PATCH 17/17] Add a missing Action repo link --- ...istribution-releases-using-github-actions-ci-cd-workflows.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst index 7cdc5169d1..6f79251e8d 100644 --- a/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst +++ b/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst @@ -147,6 +147,7 @@ sure that your release pipeline remains healthy! .. _GitHub Actions CI/CD: https://github.com/features/actions .. _join the waitlist: https://github.com/features/actions/signup .. _pypa/gh-action-pypi-publish: + https://github.com/pypa/gh-action-pypi-publish .. _`pypa/gh-action-pypi-publish GitHub Action`: https://github.com/marketplace/actions/pypi-publish .. _Secrets: