🚀 Deploy package to PyPI #19
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
name: Deploy package to PyPI | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- musify/** | |
pull_request_target: | |
branches: [ master ] | |
paths: | |
- musify/** | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
test_windows: | |
name: Run tests - Windows 🪟 | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '>=3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install '.[test]' | |
- name: Run tests | |
run: | | |
pytest --junit-xml=test-results.xml | |
- name: Publish test results report | |
if: always() | |
uses: pmeier/pytest-results-action@main | |
with: | |
path: test-results.xml | |
summary: true | |
display-options: fEX | |
fail-on-empty: true | |
title: Test results - Windows 🪟 | |
test_linux: | |
name: Run tests - Linux 🐧 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '>=3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install '.[test]' | |
- name: Run tests | |
run: | | |
pytest --junit-xml=test-results.xml | |
- name: Publish test results report | |
if: always() | |
uses: pmeier/pytest-results-action@main | |
with: | |
path: test-results.xml | |
summary: true | |
display-options: fEX | |
fail-on-empty: true | |
title: Test results - Linux 🐧 | |
test_mac: | |
name: Run tests - Mac 🍎 | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '>=3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install '.[test]' | |
- name: Run tests | |
run: | | |
pytest --junit-xml=test-results.xml | |
- name: Publish test results report | |
if: always() | |
uses: pmeier/pytest-results-action@main | |
with: | |
path: test-results.xml | |
summary: true | |
display-options: fEX | |
fail-on-empty: true | |
title: Test results - Mac 🍎 | |
build: | |
name: Build package 📦 | |
runs-on: ubuntu-latest | |
needs: [test_windows, test_linux, test_mac] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '>=3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install hatch | |
- name: Build package | |
run: | | |
hatch build | |
- name: Upload package artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
if-no-files-found: error | |
deploy: | |
name: Publish to PyPI 🚀 | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/master' | |
environment: | |
name: pypi | |
url: https://pypi.org/p/musify | |
permissions: | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download package artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |