Skip to content

ci: fix release workflow to be triggered on tags #9

ci: fix release workflow to be triggered on tags

ci: fix release workflow to be triggered on tags #9

Workflow file for this run

name: Build sdist and wheels and publish them to PyPI when a release tag is created in master branch
on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:
jobs:
build_dist:
name: Build distribution
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Set up pip cache
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: ${{ runner.os }}-pip-
- name: Install hatch
run: |
pipx install hatch
hatch --version
- name: Build the package
run: |
hatch build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*
if-no-files-found: error
publish:
if: contains(github.ref, '/tags/v')
needs: [build_dist]
runs-on: ubuntu-latest
environment: PyPI Release
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
- name: Publish sdist and wheels to PyPI
uses: pypa/gh-action-pypi-publish@v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verify-metadata: false