name: Semantic Release
on:
push:
branches:
- main
permissions:
contents: write
actions: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
concurrency: release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v8.7.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
if: steps.release.outputs.released == 'true'
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Hatch
if: steps.release.outputs.released == 'true'
run: pip install hatch
- name: Build project
if: steps.release.outputs.released == 'true'
run: hatch build
- name: Store the distribution packages
if: steps.release.outputs.released == 'true'
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
retention-days: 5
compression-level: 9
if-no-files-found: error
# Trigger the PyPI publish workflow if a new release was created
- name: Trigger PyPI publish workflow
if: steps.release.outputs.released == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'pypi-publish.yml',
ref: 'main'
})