Files
scribe/.github/workflows/pypi.yml
T
Schmieder, Jacob 35b5682d96 try to find venv
2024-05-16 07:42:44 +00:00

88 lines
2.7 KiB
YAML

name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
on:
push:
branches:
- pyproject.toml # test branch for testing the workflow
tags:
- v* # Push tags to trigger the workflow
workflow_dispatch:
inputs:
test:
description: "Push to TestPyPI not PyPI"
default: true
type: boolean
jobs:
Build-and-publish-to-Test-PyPI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Poetry 📦
if: ${{ !(startsWith(github.ref, 'refs/tags')) }}
uses: JRubics/poetry-publish@v1.16
with:
pypi_token: ${{ secrets.TEST_PYPI_API_TOKEN }}
plugins: "poetry-dynamic-versioning"
repository_name: "scraibe"
repository_url: "https://test.pypi.org/legacy/"
- name: List virtual environments
run: ls -la /github/home/.cache/pypoetry/virtualenvs
- name: Get the virtual environment path
run: echo "VENV_PATH=$(ls -d $HOME/.cache/pypoetry/virtualenvs/* | head -n 1)" >> $GITHUB_ENV
- name: Activate the virtual environment and get version
run: |
source $VENV_PATH/bin/activate
VERSION=$(python -c "import scraibe; print(scraibe.__version__)")
echo "SCRAIBE_VERSION=$VERSION" >> $GITHUB_ENV
echo "SCRAIBE_VERSION=$VERSION"
env:
VENV_PATH: ${{ env.VENV_PATH }}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: build
path: ./sdist
retention-days: 5
test-install:
name: Test Installation from TestPyPI
needs: Build-and-publish-to-Test-PyPI
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install package
run: |
python3 -m pip install setuptools
python3 -m pip install --index-url https://test.pypi.org/simple/ scraibe
# publish-to-pypi:
# name: Conditional Publish to PyPI or Dev Repository
# needs: [build, test-install]
# runs-on: ubuntu-latest
# environment:
# name: pypi
# url: env.PyPI_URL
# permissions:
# id-token: write
# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v3
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution 📦 to PyPI or Dev Repository
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: ${{ github.ref == 'refs/heads/main' && 'env.PyPI_URL' || ' env.PyPI_DEV_URL' }}
# password: ${{ secrets.PYPI_API_TOKEN}}