Skip to content

Update release.yml

Update release.yml #5

Workflow file for this run

name: Publish Python Package
on:
push:
tags:
- 'v*.*.*' # Triggers on tags like v1.0.0, v2.1.3, etc.
jobs:
publish:
runs-on: ubuntu-22.04 # Specifies the exact Ubuntu version
permissions:
contents: write # Grants write access to repository contents, including releases
steps:
- name: Checkout Repository
uses: actions/checkout@v4.2.0 # Exact version of checkout action
- name: Set up Python
uses: actions/setup-python@v4.4.0 # Exact version of setup-python action
with:
python-version: '3.11' # Specify your desired Python version
cache: 'pip' # Enables pip caching
- name: Cache pip Dependencies
uses: actions/cache@v4.0.2 # Exact version of cache action
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt', 'setup.py', 'pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Build Tools
run: |
python -m pip install --upgrade pip
pip install build==0.10.0 twine==4.0.2 # Install exact versions of build and twine
- name: Install Dependencies
run: |
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip install .
- name: Run Tests
run: |
python -m unittest discover -s Tests
# Ensure you have a 'Tests' directory with your test suites
- name: Build Package
run: |
python -m build
# This creates both sdist and wheel in the 'dist/' directory
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m twine upload dist/*
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1.1.4 # Exact version of create-release action
with:
tag_name: ${{ github.ref_name }} # Correctly extracted tag name
release_name: Release ${{ github.ref_name }} # Correctly extracted release name
body: "Automated release of `${{ github.ref_name }}`"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}