Skip to content

Commit

Permalink
Publish to pypi only once in github actions (#47)
Browse files Browse the repository at this point in the history
Publish to pypi only once in github actions

Notes:

* Github Actions does not support env in job strategy: actions/runner#480 (comment)

* 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
  • Loading branch information
pdecat authored Mar 21, 2021
1 parent d34af49 commit 85c57ac
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
35 changes: 30 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
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

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
Expand All @@ -19,13 +29,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/[email protected]
uses: pypa/[email protected]
with:
password: ${{ secrets.pypi_password }}
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 85c57ac

Please sign in to comment.