Skip to content

Commit

Permalink
add a publish.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Nov 15, 2024
1 parent aad1a2e commit c9c51f0
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
104 changes: 104 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c9c51f0

Please sign in to comment.