diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6a45c17 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python: ["3.9", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - run: python -m pip install --upgrade pip build twine + - run: python -m build + - run: python -m twine check dist/* + - name: Install the wheel and import it + run: | + python -m pip install dist/*.whl + cd /tmp && python -c "import odds_api; print(odds_api.__name__)" + - name: Run tests if present + run: | + if [ -d tests ]; then + python -m pip install pytest pytest-asyncio "responses>=0.23.0" "pandas>=1.3" "websockets>=10.0" + python -m pytest + fi diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5eb3075 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,54 @@ +name: Publish + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Check release tag matches pyproject.toml + run: | + TAG="${GITHUB_REF_NAME#v}" + VERSION="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")" + if [ "$VERSION" != "$TAG" ]; then + echo "pyproject.toml version $VERSION does not match release tag $TAG"; exit 1 + fi + - run: python -m pip install --upgrade pip build twine + - run: python -m build + - run: python -m twine check dist/* + - name: Install the wheel and import it + run: | + python -m pip install dist/*.whl + cd /tmp && python -c "import odds_api" + - name: Run tests if present + run: | + if [ -d tests ]; then + python -m pip install pytest pytest-asyncio "responses>=0.23.0" "pandas>=1.3" "websockets>=10.0" + python -m pytest + fi + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + pypi: + needs: build + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1