diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index a25fc7d..add4ed7 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -16,10 +16,9 @@ permissions: contents: read jobs: - deploy: + build-artifact: + name: Build package runs-on: ubuntu-latest - permissions: - id-token: write steps: - uses: actions/checkout@v3 - name: Set up Python @@ -31,6 +30,76 @@ jobs: python -m pip install --upgrade pip pip install build - name: Build package - run: python -m build + run: | + python -m build + echo "" + echo "Generated files:" + ls -lh dist/ + - uses: actions/upload-artifact@v3 + with: + name: releases + path: dist + test-built-dist: + name: Test package + needs: build-artifact + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - uses: actions/download-artifact@v3 + with: + name: releases + path: dist + - name: List contents of built dist + run: | + ls -ltrh + ls -ltrh dist + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + # TODO: Set up TEST_PYPI_API_TOKEN secret in GitHub Actions settings + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ + verbose: true + skip_existing: true + - name: Check pypi packages + id: check_pkg + run: | + # Install local wheel to get the version number + echo "=== Testing wheel file ===" + pip install dist/autora_doc*.whl + latest_version="$(python -c 'from autora import doc; print(doc.__version__)')";export latest_version + echo "latest_version=$latest_version" >> $GITHUB_OUTPUT + echo "=== Got version $latest_version from local wheel install ===" + python -m pip uninstall --yes autora-doc + sleep 5 + + python -m pip install --upgrade pip + echo "=== Testing Test PyPi installation ===" + # Install wheel to get dependencies and check import + python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre autora-doc==$latest_version + echo "=== Done testing Test PyPi file ===" + echo "=== Testing source tar file ===" + # Install tar gz and check import + python -m pip uninstall --yes autora-doc + python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=autora-doc autora-doc==$latest_version + python -c "from autora import doc; print(doc.__version__)" + echo "=== Done testing source tar file ===" + outputs: + package-version: ${{steps.check_pkg.outputs.latest_version}} + publish: + name: Publish distribution 📦 to PyPI + needs: test-built-dist + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v3 + with: + name: releases + path: dist - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/src/autora/doc/__init__.py b/src/autora/doc/__init__.py index e69de29..8dee4bf 100644 --- a/src/autora/doc/__init__.py +++ b/src/autora/doc/__init__.py @@ -0,0 +1 @@ +from ._version import __version__