Skip to content

9.4.1

9.4.1 #5

Workflow file for this run

---
name: Test & Release
on:
push:
branches:
- master
- main
- "pre/*"
jobs:
test:
name: Python ${{ matrix.python-version }} tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install .[test]
python -m pip install pytest-github-actions-annotate-failures
- name: pytest
run: PYTHONHASHSEED=123345 python -m pytest -v tests
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install mypy & dev packages
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ".[dev, mypy]"
- name: ruff
run: |
python -m ruff check . \
--config pyproject.toml \
--diff \
--show-source \
--exit-non-zero-on-fix
- name: mypy
run: |
python -m mypy --ignore-missing-imports semantic_release
beautify:
name: Beautify
runs-on: ubuntu-latest
concurrency: push
needs: [test, lint]
outputs:
new_sha: ${{ steps.sha.outputs.SHA }}
permissions:
id-token: write
contents: write
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Ruff
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ".[dev]"
- name: Format
run: |
python -m ruff format .
- name: Commit and push changes
uses: github-actions-x/commit@v2.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "style: beautify ${{ github.sha }}"
name: github-actions
email: action@github.com
- name: Get new SHA
id: sha
run: |
new_sha=$(git rev-parse HEAD)
echo "SHA=$new_sha" >> $GITHUB_OUTPUT
release:
name: Semantic Release
runs-on: ubuntu-latest
concurrency: push
needs: [test, lint, beautify]
if: github.repository == 'python-semantic-release/python-semantic-release'
environment:
name: pypi
url: https://pypi.org/project/python-semantic-release/
permissions:
# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#metadata
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Python Semantic Release
id: release
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
root_options: "-vv"
# see https://docs.pypi.org/trusted-publishers/
- name: Publish package distributions to PyPI
id: pypi-publish
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
# See https://github.com/actions/runner/issues/1173
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
- name: Publish package distributions to GitHub Releases
id: github-release
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
# See https://github.com/actions/runner/issues/1173
if: steps.release.outputs.released == 'true'
uses: python-semantic-release/upload-to-gh-release@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}