diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000000000000000000000000000000000000..9534d1852311d26c9745dd780f4a1ea50869744b
--- /dev/null
+++ b/.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:
+ name: publish
+ needs: [tests] # require tests to pass before deploy runs
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout source
+ uses: actions/checkout@v3
+ - name: Set up Python 3.9
+ uses: actions/setup-python@v4
+ with:
+ python-version: 3.9
+ - name: Install flit
+ run: |
+ pip install flit~=3.6
+
+ - name: Build and publish
+ run: |
+ flit publish
+ env:
+ FLIT_USERNAME: __token__
+ FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index aa7e74a2bf699325c364982b2e4ceabc7e2080ac..f64c6ef149992ac3739c880fe8b67c4ef7d6ea6f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -6,6 +6,7 @@ on:
tags:
- 'v*'
pull_request:
+ workflow_call:
env:
# Force colors for logs
@@ -109,27 +110,3 @@ jobs:
- name: Run pytest
run: pytest --durations=10 -m 'not requires_tex'
-
- publish:
-
- name: Publish to PyPi
- needs: [pre-commit, test-with-cov, tests]
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout source
- uses: actions/checkout@v3
- - name: Set up Python 3.9
- uses: actions/setup-python@v4
- with:
- python-version: 3.9
- - name: Install flit
- run: |
- pip install flit~=3.6
-
- - name: Build and publish
- run: |
- flit publish
- env:
- FLIT_USERNAME: __token__
- FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}