diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3b4f0a4 --- /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: + 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 }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2665362..f8d0c22 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,7 @@ on: pull_request: schedule: - cron: "0 8 * * *" + workflow_call: jobs: pre-commit: @@ -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 @@ -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