Skip to content

more badges, automate release workflows #11

more badges, automate release workflows

more badges, automate release workflows #11

name: Publish and Release Python Package
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for trusted publishing to PyPI
contents: write # Required for creating releases and uploading assets
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run Tests
run: poetry run pytest
- name: Build the package
if: success()
run: poetry build
- name: Publish to PyPI
if: success()
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
if: success()
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }} # Use the current tag
release_name: Release ${{ github.ref }} # Name the release
body: |
Automated release for version ${{ github.ref }}
draft: false
prerelease: false
- name: Upload .whl to GitHub Release
if: success()
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/*.whl
asset_name: package.whl
asset_content_type: application/zip
- name: Upload .tar.gz to GitHub Release
if: success()
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/*.tar.gz
asset_name: package.tar.gz
asset_content_type: application/gzip