Thanks to visit codestin.com
Credit goes to github.com

Skip to content

2.2.0: overall quality improvements #35

2.2.0: overall quality improvements

2.2.0: overall quality improvements #35

Workflow file for this run

# This workflow checks out a new release and publishes it to PyPI using Poetry.
#
# First it builds a wheel for every combination of OS and Python version listed, save for Python 3.12 on ubuntu-latest.
# It then starts an ubuntu-latest instance that retrieves all built wheels, and builds a wheel for Python 3.12 and a source distribution.
# Finally it uploads the source and all wheels to PyPI.
name: Publish Package
# Controls when the workflow will run
on:
# Workflow will run when a release has been published for the package
release:
types:
- published
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build_platform_specific_wheels:
name: Build for Python ${{ matrix.pyversion }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix: # important: if this matrix is changed, also change EXPECTED_WHEELS_COUNT in `build_and_publish_as_package` below
os: [ubuntu-latest, macos-latest, windows-latest]
pyversion: ["3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- os: ubuntu-latest
pyversion: "3.12" # exclude because we already use this OS and version for building the source package
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyversion }}
- name: Setup Poetry
uses: Gr1N/setup-poetry@v9
- name: Build wheel distribution
run: |
poetry install
poetry build -f wheel
ls ./dist
- name: Upload the built wheel distribution
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}_${{ matrix.pyversion }}
path: ./dist/*.whl
if-no-files-found: error
build_and_publish_as_package:
name: Package and upload release to PyPI
needs: [build_platform_specific_wheels]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/python-constraint2
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Build the source distribution and platform-specific wheel
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Setup Poetry
uses: Gr1N/setup-poetry@v9
- name: Build for Python 3.12 on ubuntu-latest
run: |
poetry install
poetry build
ls ./dist
- name: Download all platform-specific wheels to the `temp_dist` folder
uses: actions/download-artifact@v4
with:
path: ./temp_dist
- name: Unpack the remotely built wheels to the `dist` folder
run: | # searches for wheel files in all subdirectories of ./temp_dist and moves the files to ./dist
echo "Received artifacts:"
ls ./temp_dist
echo "\n"
mkdir -p ./dist
find ./temp_dist -name '*.whl' -exec mv {} ./dist \;
echo "Unpacked files:"
ls ./dist
echo "\n"
rm -rf ./temp_dist
- name: Check that the number of wheels is as expected and there is one source distribution
run: |
SOURCES_COUNT=$(ls -lR ./dist/*.tar.gz | wc -l)
echo "Number of source distributions: $SOURCES_COUNT"
if [ "$SOURCES_COUNT" -ne 1 ]; then
echo "::error::Number of source distributions $SOURCES_COUNT not equal to 1"
exit 1;
fi
EXPECTED_WHEELS_COUNT=15
WHEELS_COUNT=$(ls -lR ./dist/*.whl | wc -l)
echo "Number of wheel distributions: $WHEELS_COUNT"
if [ "$WHEELS_COUNT" -ne "$EXPECTED_WHEELS_COUNT" ]; then
echo "::error::Number of wheel distributions $WHEELS_COUNT not equal to $EXPECTED_WHEELS_COUNT"
exit 1;
fi
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true