Skip to content

ci: add GitHub Actions for PR checks and PyPI release #1

ci: add GitHub Actions for PR checks and PyPI release

ci: add GitHub Actions for PR checks and PyPI release #1

Workflow file for this run

name: Release
on:
push:
branches: [main]
paths-ignore:
- "*.md"
- "docs/**"
- "history/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
id-token: write
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: uv sync
- name: Run tests
run: uv run pytest
version:
name: Bump version and create tag
needs: test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.versioning.outputs.version }}
tag: ${{ steps.versioning.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and create tag
id: versioning
run: |
uv version --bump patch
NEW_VERSION=$(uv version --short)
TAG="v$NEW_VERSION"
sed -i "s/__version__ = .*/__version__ = \"$NEW_VERSION\"/" src/conversation_exporter/__init__.py
git add pyproject.toml src/conversation_exporter/__init__.py
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
git tag -a "$TAG" -m "Release $TAG"
git push origin main
git push origin "$TAG"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
pypi:
name: Publish to PyPI
needs: version
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/conversation-exporter
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build and publish to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv build
uv publish --token $UV_PUBLISH_TOKEN
- name: Store distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
github-release:
name: Create GitHub Release
needs: [version, pypi]
runs-on: ubuntu-latest
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign distributions
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create '${{ needs.version.outputs.tag }}'
--repo '${{ github.repository }}'
--generate-notes
dist/*