Documentation refinements (#14) #110
Workflow file for this run
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: Build-n-publish distribution | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
env: | |
python-version: "3.12" | |
jobs: | |
build-distribution: | |
name: Build distribution | |
runs-on: ubuntu-latest | |
steps: | |
# Check out only a limited depth and then pull tags to save time | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
- name: Get tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python-version }} | |
- name: Install build tools | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade build | |
python -m pip install --upgrade twine | |
- name: Build packages | |
run: python -m build | |
- name: Check metadata verification | |
run: python -m twine check --strict dist/* | |
- name: Upload artifact with distribution files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: distro-files | |
path: dist/ | |
if-no-files-found: warn | |
retention-days: 1 # delete the artifact after 1 day, no need to keep it for too long | |
compression-level: 0 # no need to compress the files | |
- name: Distribution files & installation sizes | |
run: | | |
echo "Distribution files sizes" | |
du -sh dist/* | |
python -m pip install dist/*.whl --target /tmp/pvpltools --quiet --quiet | |
echo "Installation sizes" | |
du -sh /tmp/pvpltools | |
publish-distribution: | |
name: Upload distribution to PyPI | |
runs-on: ubuntu-latest | |
needs: build-distribution # only publish distribution after building it | |
# only publish distribution to PyPI for tagged commits | |
if: github.repository == 'pvplabs/pvpltools' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
environment: release | |
permissions: | |
# permission mandatory for trusted publishing | |
id-token: write | |
steps: | |
- name: Download artifact with distribution files | |
uses: actions/download-artifact@v4 | |
with: | |
name: distro-files | |
path: dist/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |