From be56b47e72f9f5ab015bdc4e87b946da69046ac1 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Sat, 13 Mar 2021 10:18:59 +0100 Subject: [PATCH 1/3] Publish to pypi only once in github actions --- .github/workflows/main.yml | 28 +++++++++++++++++++++++----- HISTORY.rst | 4 ++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6738c36..4ad4b82 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,13 +2,16 @@ name: Python package on: [push, pull_request] +env: + target_python_version: 3.8 + jobs: - build: + test: runs-on: ubuntu-latest strategy: max-parallel: 5 matrix: - python-version: [3.7, 3.8] + python-version: [3.7, "${{env.target_python_version}}"] steps: - uses: actions/checkout@v1 @@ -19,13 +22,28 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-gh-actions wheel + pip install tox tox-gh-actions - name: Test with tox run: tox + + publish: + needs: test + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{env.target_python_version}} + uses: actions/setup-python@v2 + with: + python-version: ${{env.target_python_version}} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install wheel - name: Build distributions run: python setup.py sdist bdist_wheel --universal - name: Upload release to pypi - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.4.1 + uses: pypa/gh-action-pypi-publish@v1.4.2 with: password: ${{ secrets.pypi_password }} diff --git a/HISTORY.rst b/HISTORY.rst index d209c5d..2c7c8b4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -135,3 +135,7 @@ History ------------------ * Support newer openwrt snapshot versions (#45) * Fix tox in github actions and also test py38 (#46) + +1.1.x (unreleased) +------------------ +* Publish to pypi only once in github actions (#47) From 9efe9a181dbfe77fc9bebd1f5ac9f47c2dc97f22 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Sat, 20 Mar 2021 09:19:47 +0100 Subject: [PATCH 2/3] Github Actions does not support env in job strategy --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ad4b82..0e87f6a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: [3.7, "${{env.target_python_version}}"] + python-version: [3.7, 3.8] steps: - uses: actions/checkout@v1 From f21f54dc4a75dc856ba1d4f73c2ad30e0407e2d3 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Sat, 20 Mar 2021 09:28:11 +0100 Subject: [PATCH 3/3] Trigger the workflow on push or pull request, but only for the master branch, see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-multiple-events-with-activity-types-or-configuration --- .github/workflows/main.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e87f6a..ab551f4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,13 @@ name: Python package -on: [push, pull_request] +on: + # Trigger the workflow on push or pull request, but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master env: target_python_version: 3.8