Skip to content

Commit

Permalink
build: use a dedicated publish workflow (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Dec 28, 2023
1 parent a2885e0 commit 2cd0f59
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,32 @@
# This will run every time a tag is created and pushed to the repository.
# It calls our tests workflow via a `workflow_call`, and if tests pass
# then it triggers our upload to PyPI for a new release.
name: Publish to PyPI
on:
release:
types: ["published"]

jobs:
tests:
uses: ./.github/workflows/tests.yml

publish:
needs: [tests]
name: Publish to PyPi
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.10
- name: Build package
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: __token__
password: ${{ secrets.PYPI_KEY }}
39 changes: 6 additions & 33 deletions .github/workflows/tests.yml
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
schedule:
- cron: "0 8 * * *"
workflow_call:

jobs:
pre-commit:
Expand Down Expand Up @@ -36,11 +37,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
- name: Install hatch
run: pip install hatch
- name: Run tests
run: hatch run test:test -x

Expand All @@ -49,32 +47,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
- name: Install hatch
run: pip install hatch
- name: Build docs
run: |
hatch run doc:build
publish:
name: Publish to PyPi
needs: [tests]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Build package
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: __token__
password: ${{ secrets.PYPI_KEY }}
run: hatch run doc:build

0 comments on commit 2cd0f59

Please sign in to comment.