From abacae24059bbd2db41273717ac280262956bb74 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 25 Jan 2025 15:36:28 -0500 Subject: [PATCH] update ci to add deploy --- .github/workflows/ci.yaml | 74 ++++++++++++++++++++++++++++++++++ .github/workflows/publish.yaml | 34 ---------------- .github/workflows/tests.yaml | 33 --------------- 3 files changed, 74 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/publish.yaml delete mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b65d52f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,74 @@ +name: CI + +on: + push: + branches: [main] + tags: [v*] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run pre-commit + run: pipx run pre-commit run --all-files + + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install ".[dev]" + - name: Test with pytest + run: | + pytest --color=yes -v tests + + deploy: + name: Deploy + needs: test + if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' + runs-on: ubuntu-latest + + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: 🐍 Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: 👷 Build + run: | + python -m pip install build + python -m build + + - name: 🚢 Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + - uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + files: "./dist/*" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index a364b60..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish - -on: - push: - tags: "*" - -jobs: - build-n-publish: - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install pypa/build - run: >- - python -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ - - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml deleted file mode 100644 index 7f5bcca..0000000 --- a/.github/workflows/tests.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test - -on: [push, pull_request] - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run pre-commit - run: pipx run pre-commit run --all-files - - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install ".[dev]" - - name: Test with pytest - run: | - pytest --color=yes -v tests