From 187ca313d184ee7bebd2a845560f4bdc0f7209bf Mon Sep 17 00:00:00 2001 From: Michael Engen Date: Sat, 20 Aug 2022 20:29:14 -0400 Subject: [PATCH 1/2] build: add semantic release publish features. --- .github/workflows/ci-cd.yml | 37 ++++++++++++++++++++++++++++++++++++- pyproject.toml | 10 +++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index e3e0f6a..9827bfb 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -22,4 +22,39 @@ jobs: - name: Test with pytest run: poetry run pytest tests/ - name: Build documentation - run: poetry run make html --directory docs/ \ No newline at end of file + run: poetry run make html --directory docs/ + + cd: + # Only run this job if the "ci" job passes + needs: ci + + # Only run this job if new work is pushed to the "master" branch + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + # Set up operating system + runs-on: ubuntu-latest + + # Define job steps + steps: + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Check-out repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install poetry + uses: snok/install-poetry@v1 + + - name: Install package + run: poetry install + + - name: Use Python Semantic Release to prepare release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + poetry run semantic-release publish \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b212c6a..980a60a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,15 @@ sphinx-autoapi = "^1.8.4" sphinx-rtd-theme = "^1.0.0" [tool.semantic_release] -version_variable = "pyproject.toml:version" +version_variable = "pyproject.toml:version" # version location +branch = "master" # branch to make releases of +changelog_file = "CHANGELOG.md" # changelog file +build_command = "poetry build" # build dists +dist_path = "dist/" # where to put dists +upload_to_release = true # auto-create GitHub release +upload_to_pypi = false # don't auto-upload to PyPI +remove_dist = false # don't remove dists +patch_without_tag = true # patch release by default [build-system] requires = ["poetry-core>=1.0.0"] From 5d908b5b8a92dbc816be8c001aa48bb27926911a Mon Sep 17 00:00:00 2001 From: Michael Engen Date: Mon, 5 Sep 2022 06:19:17 -0400 Subject: [PATCH 2/2] build: Add PYPI integration --- .github/workflows/ci-cd.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9827bfb..806e16a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -57,4 +57,31 @@ jobs: run: | git config user.name github-actions git config user.email github-actions@github.com - poetry run semantic-release publish \ No newline at end of file + poetry run semantic-release publish + + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + - name: Test install from TestPyPI + run: | + pip install \ + --index-url https://test.pypi.org/simple/ \ + --extra-index-url https://pypi.org/simple \ + permpy + + - name: Test install from TestPyPI + run: | + pip install \ + --index-url https://test.pypi.org/simple/ \ + --extra-index-url https://pypi.org/simple \ + pycounts + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file