Publish to PyPI #121
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: Publish to PyPI | |
on: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
PYTHON_VERSION: "3.10" | |
outputs: | |
sdist-package-name: ${{ steps.build-package.outputs.sdist-package-name }} | |
bdist-package-name: ${{ steps.build-package.outputs.bdist-package-name }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- id: build-package | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install setuptools | |
python3 -m pip install wheel | |
python3 -m pip install build | |
python3 -m pip install . | |
python3 -m build | |
VERSION=${{ github.event.release.tag_name }} | |
SDIST_PACKAGE_NAME="schematicpy-${VERSION}.tar.gz" | |
BDIST_PACKAGE_NAME="schematicpy-${VERSION}-py3-none-any.whl" | |
RELEASE_URL_PREFIX="https://uploads.github.com/repos/${{ github.event.repository.full_name }}/releases/${{ github.event.release.id }}/assets?name=" | |
echo "sdist-package-name=$SDIST_PACKAGE_NAME" >> $GITHUB_OUTPUT | |
echo "bdist-package-name=$BDIST_PACKAGE_NAME" >> $GITHUB_OUTPUT | |
echo "sdist-release-url=${RELEASE_URL_PREFIX}${SDIST_PACKAGE_NAME}" >> $GITHUB_OUTPUT | |
echo "bdist-release-url=${RELEASE_URL_PREFIX}${BDIST_PACKAGE_NAME}" >> $GITHUB_OUTPUT | |
- name: upload-sdist-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build-package.outputs.sdist-package-name }} | |
path: dist/ | |
if-no-files-found: error | |
- name: upload-bdist-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build-package.outputs.bdist-package-name }} | |
path: dist/ | |
if-no-files-found: error | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ github.event.release.prerelease == 'true' && 'pypi' || 'testpypi' }} | |
url: ${{ github.event.release.prerelease == 'true' && 'https://pypi.org/p/schematicpy' || 'https://test.pypi.org/p/schematicpy' }} | |
permissions: | |
id-token: write | |
steps: | |
- name: debug prerelease | |
run: | | |
echo "prerelease: ${{ github.event.release.prerelease }}" | |
echo "name: ${{ github.event.release.prerelease == 'true' && 'pypi' || 'testpypi' }}" | |
echo "url: ${{ github.event.release.prerelease == 'true' && 'https://pypi.org/p/schematicpy' || 'https://test.pypi.org/p/schematicpy' }}" | |
# - name: download-sdist | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: ${{ needs.build.outputs.sdist-package-name }} | |
# path: dist | |
# - name: download-bdist | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: ${{ needs.build.outputs.bdist-package-name }} | |
# path: dist | |
# - name: deploy-to-test-pypi | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ |