This directory contains GitHub Actions workflows for the SinricPro Python SDK.
Trigger: Automatically runs on pull requests to main branches
Purpose: Validates code quality and ensures all examples compile correctly
Jobs:
-
validate-examples: Tests all example files across Python 3.10, 3.11, and 3.12
- Uses
.github/scripts/validate_examples.pyto validate syntax and imports - Validates Python syntax using AST parsing
- Tests that all sinricpro imports work correctly
- Uses
-
lint-check: Runs code quality checks
- Ruff for code linting
- MyPy for type checking
-
package-build: Tests package building
- Builds wheel and source distribution
- Validates with
twine check
What it validates:
- ✅ All example files have valid Python syntax
- ✅ All imports in examples are correct
- ✅ Package can be built successfully
- ✅ Code passes linting checks (non-blocking)
- ✅ Type hints are correct (non-blocking)
Trigger: Manual workflow dispatch
Purpose: Publishes a new version to PyPI and creates a GitHub release
Required Secrets:
PYPI_API_TOKEN: PyPI API token for publishing packages- Get from: https://pypi.org/manage/account/token/
- Add to: Repository Settings → Secrets and variables → Actions → New repository secret
Input Parameters:
version: Version number (e.g.,3.0.0or3.0.0-beta.1)branch: Branch or tag to publish from (default:main)prerelease: Mark as pre-release (checkbox)
Jobs:
-
validate-version
- Validates version format (X.Y.Z or X.Y.Z-suffix)
- Checks that git tag doesn't already exist
-
build-and-test
- Updates version in
sinricpro/__init__.py - Builds package (wheel + source distribution)
- Validates with
twine check - Tests local installation
- Uploads artifacts for next jobs
- Updates version in
-
publish-to-pypi
- Downloads build artifacts
- Publishes to PyPI using official PyPI publish action
- Waits for propagation
- Verifies package is available on PyPI
-
create-github-release
- Creates and pushes git tag (
vX.Y.Z) - Generates changelog from git commits
- Creates GitHub release with:
- Release notes
- Attached wheel and source files
- Links to PyPI package
- Creates and pushes git tag (
Workflow Summary: After successful completion, the workflow creates a summary with:
- Version number
- PyPI package link
- GitHub release link
- Installation command
-
Create PyPI API Token:
# Go to https://pypi.org/manage/account/token/ # Create a new API token with scope: "Entire account" or specific to "sinricpro" # Copy the token (starts with pypi-...)
-
Add Token to GitHub Secrets:
- Go to repository Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
PYPI_API_TOKEN - Value: Paste your PyPI token
- Click "Add secret"
-
Go to Actions tab in your repository
-
Select "Publish Release to PyPI" from the workflows list
-
Click "Run workflow" button
-
Fill in the parameters:
- Version: Enter version number (e.g.,
3.0.1) - Branch: Select branch to publish from (usually
main) - Prerelease: Check if this is a pre-release version
- Version: Enter version number (e.g.,
-
Click "Run workflow"
-
Monitor the workflow:
- Watch each job complete
- Check for any errors
- View the summary for installation instructions
Stable releases:
3.0.0- Major version3.0.1- Patch version3.1.0- Minor version
Pre-releases:
3.0.0-alpha.1- Alpha release3.0.0-beta.1- Beta release3.0.0-rc.1- Release candidate
Before publishing a release:
-
Test locally:
# Build the package python -m build # Check with twine twine check dist/* # Install locally pip install dist/*.whl # Test import python -c "import sinricpro; print(sinricpro.__version__)"
-
Test examples:
# Validate all examples python -m compileall examples/ -
Run tests (if available):
pytest tests/
"Tag already exists" error:
- The version tag already exists in git
- Choose a different version number or delete the existing tag
"PyPI upload failed" error:
- Check that
PYPI_API_TOKENsecret is set correctly - Verify token has correct permissions
- Ensure version doesn't already exist on PyPI
"Package build failed" error:
- Check
pyproject.tomlfor syntax errors - Verify all dependencies are listed correctly
- Check that version number is valid
"Import error in examples" (PR validation):
- Missing import in example file
- Typo in module name
- New module not exported in
__init__.py
The workflows require the following permissions:
contents: write- For creating tags and releasespackages: write- For publishing to PyPI (via PYPI_API_TOKEN)
These are automatically granted in the workflow files.
- Always test locally before publishing
- Use semantic versioning (semver.org)
- Write meaningful release notes
- Test examples after each change
- Keep dependencies up to date
- Tag releases consistently (vX.Y.Z format)
The .github/scripts/ directory contains helper scripts used by the workflows:
Validates all Python example files in the examples/ directory:
- Checks Python syntax using AST parsing
- Verifies that all
sinricproimports are valid - Provides detailed output for debugging
- Returns exit code 0 on success, 1 on failure
Usage:
python .github/scripts/validate_examples.pyOutput:
Found 16 Python example files
============================================================
Validating Python syntax...
============================================================
✓ Syntax valid: examples/switch/switch_example.py
✓ Syntax valid: examples/light/light_example.py
...
============================================================
Validating sinricpro imports...
============================================================
Checking: examples/switch/switch_example.py
✓ Import OK: sinricpro
...
============================================================
✅ All examples validated successfully!
If you encounter issues with the workflows:
- Check the workflow run logs in GitHub Actions
- Review the troubleshooting section above
- Open an issue in the repository