fix: update to python 3.11 at least #18
This file contains hidden or 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 SDK to PyPI | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'sdk/**' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., v1.0.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for version counting | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies and SDK | |
| working-directory: ./sdk | |
| run: | | |
| uv sync --dev | |
| uv pip install -e . | |
| - name: Run integration tests | |
| working-directory: ./sdk | |
| run: | | |
| uv run python test_integration.py | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for version counting | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Generate version and update pyproject.toml | |
| id: version | |
| working-directory: ./sdk | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| else | |
| # Auto-generate alpha version based on latest stable release tag | |
| # Get the latest version tag (e.g., v0.1.95) | |
| LATEST_TAG=$(git describe --tags --abbrev=0 --match "sdk-v*" 2>/dev/null || echo "") | |
| if [ -z "$LATEST_TAG" ]; then | |
| # No tag found, use version from pyproject.toml | |
| CURRENT_VERSION=$(grep -o 'version = "[^"]*"' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| BASE_VERSION=$(echo $CURRENT_VERSION | cut -d'a' -f1) | |
| COMMITS_SINCE=$(git rev-list --count HEAD -- .) | |
| else | |
| # Extract version from tag (remove 'sdk-v' prefix) | |
| TAG_VERSION=$(echo $LATEST_TAG | sed 's/sdk-v//') | |
| # Count commits since the tag that affected sdk/ directory | |
| COMMITS_SINCE=$(git rev-list --count ${LATEST_TAG}..HEAD -- .) | |
| # Increment patch version for next alpha series | |
| # e.g., if tag is 0.1.95, base becomes 0.1.96 | |
| MAJOR=$(echo $TAG_VERSION | cut -d. -f1) | |
| MINOR=$(echo $TAG_VERSION | cut -d. -f2) | |
| PATCH=$(echo $TAG_VERSION | cut -d. -f3) | |
| NEXT_PATCH=$((PATCH + 1)) | |
| BASE_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}" | |
| fi | |
| # Generate alpha version with commit count | |
| VERSION="${BASE_VERSION}a${COMMITS_SINCE}" | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Publishing version: $VERSION" | |
| # Update version in pyproject.toml | |
| sed -i "s/version = \".*\"/version = \"$VERSION\"/" pyproject.toml | |
| # Update version in version.py | |
| if [ -f "klyne/version.py" ]; then | |
| sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" klyne/version.py | |
| fi | |
| echo "Updated version to $VERSION" | |
| grep "version =" pyproject.toml | |
| - name: Build package | |
| working-directory: ./sdk | |
| run: | | |
| uv build | |
| - name: Check package contents | |
| working-directory: ./sdk | |
| run: | | |
| uv run python -m tarfile -l dist/*.tar.gz | |
| ls -la dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: sdk/dist/ | |
| # Use trusted publishing (no API token needed) | |
| # Make sure to configure trusted publishing in PyPI project settings | |
| test-install: | |
| needs: publish | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Wait for package availability | |
| run: | | |
| # Wait a bit for the package to be available on PyPI | |
| sleep 30 | |
| - name: Test installation | |
| run: | | |
| pip install klyne | |
| python -c "import klyne; print('Klyne SDK installed successfully')" |