Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate the build #15

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/publish_to_pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,32 @@ jobs:
with:
python-version: '3.9'

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
# pip install setuptools wheel twine

- name: Configure Poetry Authentication
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
# Only needed if you publish to Test PyPI
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_API_TOKEN }}

- name: Build package
run: |
python setup.py sdist bdist_wheel
poetry build

- name: Publish to Test PyPI
if: startsWith(github.ref, 'refs/tags/test-')
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
run: |
poetry publish --repository testpypi

- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry publish
23 changes: 23 additions & 0 deletions DEV_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Local Development

## Configure Test PyPI for Poetry

For publishing packages to Test PyPI using Poetry during development, it is recommended to use an environment variable for the Test PyPI token. This avoids issues with keychain access on macOS and is generally simpler for automation and scripting.

### Setting Up Environment Variable for Test PyPI Token

1. **Export the Test PyPI API Token**:

Export your Test PyPI token as an environment variable in your terminal session before running the publish command.

```bash
export POETRY_TEST_PYPI_API_TOKEN=<your_test_pypi_token>
```

2. **Run the local publish command**:

In the project root folder.

```bash
./tests/build_test_pypi.sh
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "polymind"
version = "0.1.0"
version = "0.0.10" # Update this version before publishing to PyPI
description = "PolyMind is a customizable collaborative multi-agent framework for collective intelligence and distributed problem solving."
authors = ["Yx Jiang <[email protected]>"]
license = "MIT License"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is the placeholder file used by GHA.
33 changes: 0 additions & 33 deletions setup.py

This file was deleted.

33 changes: 22 additions & 11 deletions tests/build_test_pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@
set -e

# Ensure the script is run from the project root directory
if [ ! -f "setup.py" ] && [ ! -f "pyproject.toml" ]; then
echo "Error: setup.py or pyproject.toml not found. Are you in the right directory?"
if [ ! -f "pyproject.toml" ]; then
echo "Error: pyproject.toml not found. Are you in the right directory?"
exit 1
fi

# Step 1: Build the package
echo "Building the package..."
python -m pip install --upgrade pip setuptools wheel twine
python setup.py sdist bdist_wheel
# Step 1: Install Poetry
echo "Installing Poetry..."
python -m pip install --upgrade pip
pip install poetry

# Step 2: Upload the package to Test PyPI
# Make sure the password is in the .pypirc file
echo "Uploading the package to Test PyPI..."
twine upload --repository testpypi dist/*
# Step 2: Check for the POETRY_TEST_PYPI_API_TOKEN environment variable
if [ -z "${POETRY_TEST_PYPI_API_TOKEN}" ]; then
echo "Error: POETRY_TEST_PYPI_API_TOKEN is not set."
exit 1
fi

# Step 3: Build the package using Poetry
echo "Building the package with Poetry..."
poetry build

# Step 4: Publish the package to Test PyPI using Poetry
# Make sure to set the environment variable before calling this script or within this script
echo "Publishing the package to Test PyPI with Poetry..."
export POETRY_PYPI_TOKEN_TESTPYPI="${POETRY_TEST_PYPI_API_TOKEN}"
poetry publish --repository testpypi

echo "Package uploaded successfully."
echo "Package uploaded successfully."
Loading