diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..813cb31 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,72 @@ +name: Publish to PyPI + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: latest + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Extract version from pyproject.toml + id: get_version + run: | + # Extract version from [project] section + VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") + echo "project_version=$VERSION" >> $GITHUB_OUTPUT + echo "Project version: $VERSION" + + - name: Extract tag version + id: get_tag + run: | + # Remove 'refs/tags/' prefix and optional 'v' prefix + TAG_VERSION=${GITHUB_REF#refs/tags/} + TAG_VERSION=${TAG_VERSION#v} + echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT + echo "Tag version: $TAG_VERSION" + + - name: Verify version matches tag + run: | + if [ "${{ steps.get_version.outputs.project_version }}" != "${{ steps.get_tag.outputs.tag_version }}" ]; then + echo "ERROR: Tag version (${{ steps.get_tag.outputs.tag_version }}) doesn't match project version (${{ steps.get_version.outputs.project_version }})" + echo "Please ensure your git tag matches the version in pyproject.toml [project] section" + exit 1 + fi + echo "Version verification passed" + + - name: Install dependencies + run: poetry install --only-root + + - name: Build package + run: poetry build + + - name: Verify build contents + run: | + echo "Built packages:" + ls -la dist/ + echo "Checking wheel contents:" + python -m zipfile -l dist/*.whl | head -20 + + - name: Publish to PyPI + run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} + + - name: Verify publication + run: | + echo "🎉 Successfully published beast v${{ steps.get_version.outputs.project_version }} to PyPI!" + echo "Package should be available at: https://pypi.org/project/beast-backbones/${{ steps.get_version.outputs.project_version }}/" \ No newline at end of file diff --git a/README.md b/README.md index 04771de..1b09f4d 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,23 @@ conda create --yes --name beast python=3.10 conda activate beast ``` -### Step 3: Download the repo from github and install -Move to your home directory (or wherever you would like to download the code) and install: +### Step 3: Download and install +Move to your home directory (or wherever you would like to download the code) and install via Github clone or through PyPI. + +For Github cloning: ```commandline -cd ~ git clone https://github.com/paninski-lab/beast cd beast pip install -e . ``` +For installation through PyPI: + +```commandline +pip install beast-backbones +``` + ## Usage `beast` comes with a simple command line interface. To get more information, run