Skip to content

ci(workflows): add semantic-release pipeline and PR commit linting #3

ci(workflows): add semantic-release pipeline and PR commit linting

ci(workflows): add semantic-release pipeline and PR commit linting #3

Workflow file for this run

name: Release
on:
push:
branches: [main]
workflow_dispatch:
# ┌─────────────────────────────────────────────────────────────────┐
# │ DRAFT_RELEASE │
# │ │
# │ "true" → GitHub Releases are created as drafts and PyPI │
# │ publishing is skipped (burn-in / review period). │
# │ "false" → GitHub Releases are published immediately and the │
# │ package is uploaded to PyPI. │
# │ │
# │ Flip to "false" once you have verified the release output. │
# └─────────────────────────────────────────────────────────────────┘
env:
DRAFT_RELEASE: "true"
jobs:
release:
name: Semantic Release
runs-on: ubuntu-latest
if: >-
github.event_name == 'workflow_dispatch' ||
!startsWith(github.event.head_commit.message, 'chore(release):')
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build tools
run: python -m pip install -U pip build
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v9
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
if: steps.release.outputs.released == 'true'
run: python -m build
- name: Create GitHub Release
if: steps.release.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "$DRAFT_RELEASE" = "true" ]; then
DRAFT_FLAG="--draft"
fi
gh release create "${{ steps.release.outputs.tag }}" \
${DRAFT_FLAG:-} \
--title "${{ steps.release.outputs.tag }}" \
--generate-notes \
dist/*
- name: Publish to PyPI
if: steps.release.outputs.released == 'true' && env.DRAFT_RELEASE != 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true