Skip to content

Restructure pack writer hierarchy, add output_dir property #30

Restructure pack writer hierarchy, add output_dir property

Restructure pack writer hierarchy, add output_dir property #30

---
name: Test & Release
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
jobs:
validate:
name: lint and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install hatch
- run: hatch fmt --check
- run: hatch test --cover
- run: hatch run types:check
# Adapted from
# https://github.com/pypa/hatch/blob/master/.github/workflows/test.yml
- run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage*
coverage:
name: report coverage
runs-on: ubuntu-latest
# Make sure coverage reports have been generated.
needs:
- validate
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.12
- run: python -m pip install hatch
- uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true
- run: hatch run coverage:combine
- run: hatch run coverage:report-xml
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
release:
name: publish to GitHub and PyPi
runs-on: ubuntu-latest
concurrency: release
environment:
name: release
url: https://pypi.org/p/alpax
if: github.event_name == 'push'
# Make sure tests pass before running.
needs:
- validate
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.12
# Publishing steps adapted from
# https://python-semantic-release.readthedocs.io/en/latest/migrating_from_v7.html#removal-of-pypi-token-repository-username-and-repository-password-inputs.
- name: Update package version if needed
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Authentication happens via OIDC. This specific workflow and
# environment needs to be trusted in the "Publishing" settings
# for the package on PyPi.
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'