From c9c51f0517e8543e5108fbf6f5a3c03da03f4264 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Fri, 15 Nov 2024 19:53:39 +0000 Subject: [PATCH] add a publish.yml file --- .github/workflows/publish.yml | 104 ++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..34a1ba9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,104 @@ +name: Publish to PyPI + +on: + workflow_dispatch: + push: + tags: + - "v*" + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest pytest-cov pytest-asyncio + pip install -e . + + - name: Run tests + run: | + pytest tests/ --cov=web_search --cov-report=xml + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + build-and-publish: + needs: test + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/web-search-async + permissions: + id-token: write # Required for PyPI trusted publishing + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Install package & build dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install build twine + + - name: Build package + run: python -m build + + - name: Check package + run: twine check dist/* + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verify-metadata: false + skip-existing: true + verbose: true + print-hash: true + + create-release: + needs: build-and-publish + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Generate changelog + id: changelog + run: | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") + if [ -z "$PREVIOUS_TAG" ]; then + git log --pretty=format:"* %s" > CHANGELOG.md + else + git log --pretty=format:"* %s" $PREVIOUS_TAG..HEAD > CHANGELOG.md + fi + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + name: Release v${{ steps.get_version.outputs.VERSION }} + body_path: CHANGELOG.md + draft: false + prerelease: false diff --git a/pyproject.toml b/pyproject.toml index 7d3e8e5..0951658 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] name = "async-web-search" requires-python = ">=3.9" -version = "0.1.1" +version = "0.1.2" description = "Async web search library supporting Google, Wikipedia, and arXiv" readme = "README.md"