From 0e2a611197403db7d513c0f2f2b017cf95eb5dc5 Mon Sep 17 00:00:00 2001 From: David Reinhart Date: Tue, 23 Nov 2021 12:52:28 -0800 Subject: [PATCH 1/2] Adding Github action to automatically publish to pypi Publishing id3c to pypi will help standardize how this package is being installed compared to other dependencies. This will make the package simpler include in multiple applications and pin to a specific version when needed. One workflow change this will require is that commits on master branch will need to be tagged to be published to pypi.org (whereas all commits on master branch will be published to test.pypi.org). A version naming convention will need to be decided on and integrated into the deployment workflow, but the specific format chosen will not impact this PR. --- .github/workflows/cd.yaml | 37 +++++++++++++++++++++++++++++++++++++ .gitignore | 4 ++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/cd.yaml diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 00000000..0eeeee24 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,37 @@ +name: CD + +on: push + +jobs: + build-n-publish: + name: Build and publish Python distributions to PyPI and TestPyPI + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@master + - name: Set up Python 3.6 + uses: actions/setup-python@v1 + with: + python-version: 3.6 + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + - name: Publish distribution to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 79bfd7ce..79020224 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ Thumbs.db # IDE files /.vscode + +# Build and dist files +build/ +dist/ From 75a77de2a3b0a5e492ab1fe3776509bc0f0cb91b Mon Sep 17 00:00:00 2001 From: David Reinhart Date: Mon, 29 Nov 2021 13:07:07 -0800 Subject: [PATCH 2/2] Remove publishing to test.pypi.org Publishing to test.pypi.org on each push to master creates a couple of challenges. First pypi cannot overwrite a file with the same name, which is the case when publishing a package that does not have a different reference tag in github. There are some solutions to work around this by having a specific "RC" tag format for release candidates and only publishing those to test.pypi.org. At this point that would create additional unnecessary steps in the deployment process but may be worth revisiting in the future once there is a versioning/tagging conventions are established. --- .github/workflows/cd.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 0eeeee24..660fc018 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -4,7 +4,7 @@ on: push jobs: build-n-publish: - name: Build and publish Python distributions to PyPI and TestPyPI + name: Build and publish Python distribution to PyPI runs-on: ubuntu-18.04 steps: - uses: actions/checkout@master @@ -25,11 +25,6 @@ jobs: --sdist --wheel --outdir dist/ - - name: Publish distribution to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - name: Publish distribution to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master