Merge pull request #93 from r9y9/pypi #182
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Python package | |
on: | |
push: | |
branches: [ master ] | |
tags: | |
- 'v*' | |
pull_request: | |
branches: [ master ] | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
python-version: 3.8 | |
- os: ubuntu-latest | |
python-version: 3.9 | |
- os: ubuntu-latest | |
python-version: '3.10' | |
- os: ubuntu-latest | |
python-version: '3.11' | |
- os: macos-latest | |
python-version: 3.9 | |
- os: windows-latest | |
python-version: 3.9 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Lint with pysen | |
run: | | |
pysen run lint | |
- name: Test with pytest | |
run: | | |
pip install pytest | |
pytest | |
build-for-publish: | |
name: Build distribution π¦ | |
runs-on: ubuntu-latest | |
if: "startsWith(github.ref, 'refs/tags')" | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade build | |
- name: Build a source tarball and wheel | |
run: python -m build . | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
# NOTE: for now upload sdist only to prevent errors like unsupported platform tag 'linux_x86_64'. | |
path: dist/*.tar.gz | |
publish-to-pypi: | |
name: >- | |
Publish Python π distribution π¦ to PyPI | |
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
needs: | |
- build-for-publish | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/pyopenjtalk | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution π¦ to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
# NOTE: for testing purposes only | |
# publish-to-testpypi: | |
# name: Publish Python π distribution π¦ to TestPyPI | |
# needs: | |
# - build-for-publish | |
# runs-on: ubuntu-latest | |
# environment: | |
# name: testpypi | |
# url: https://test.pypi.org/p/pyopenjtalk | |
# permissions: | |
# id-token: write # IMPORTANT: mandatory for trusted publishing | |
# steps: | |
# - name: Download all the dists | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: python-package-distributions | |
# path: dist/ | |
# - name: Publish distribution π¦ to TestPyPI | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ | |
# verbose: true |