Run this one-liner to create a new Python project from this template:
# Create a public repository (default)
curl -s https://raw.githubusercontent.com/grll/mypython/main/setup.sh | bash -s YOUR_REPO_NAME
# Create a private repository
curl -s https://raw.githubusercontent.com/grll/mypython/main/setup.sh | bash -s YOUR_REPO_NAME privateThis will:
- Create a new GitHub repository from this template (public by default, or private if specified)
- Clone it locally
- Rename the package from
mypythonto your repository name (converting hyphens to underscores for Python compatibility) - Update all references throughout the codebase
For example, if you run bash -s my-awesome-project, it will create a public repo called my-awesome-project with a Python package named my_awesome_project.
Install dev dependencies:
uv sync --extra devThe dev dependencies includes linting, type checking and testing.
Install pre-commit hooks:
uv run pre-commit installRun tests:
uv run pytestThis project includes a bump_version.py script to automate version bumping and release creation. The script:
- Updates the version in
src/mypython/__init__.py - Creates a git commit with the version change
- Tags the commit with the new version
- Pushes the changes and tags to GitHub
- Creates a GitHub release with auto-generated release notes
# Bump patch version (e.g., 1.0.0 -> 1.0.1)
python scripts/bump_version.py patch
# Bump minor version (e.g., 1.0.0 -> 1.1.0)
python scripts/bump_version.py minor
# Bump major version (e.g., 1.0.0 -> 2.0.0)
python scripts/bump_version.py majorThis template includes a GitHub Actions workflow for automatic PyPI publishing when releases are created. To enable this, you need to configure PyPI Trusted Publisher:
-
Create your package on PyPI (if not already exists):
- Go to PyPI
- Upload an initial version manually or create a placeholder
-
Configure Trusted Publisher on PyPI:
- Go to your project page on PyPI
- Navigate to "Settings" → "Publishing"
- Under "Trusted Publishers", click "Add a new publisher"
- Fill in the following details:
- Owner: Your GitHub username or organization
- Repository name: Your repository name
- Workflow name:
release.yml - Environment: Leave blank (optional)
- Click "Add"
-
Verify the GitHub Actions workflow:
- The
.github/workflows/release.ymlfile is already configured in this template - It will automatically trigger when you create a new release (using
bump_version.pyor manually) - The workflow will build and publish your package to PyPI using trusted publishing (no API tokens needed!)
- The
Once configured, your release process becomes:
- Run
python scripts/bump_version.py [major|minor|patch]to create a release - GitHub Actions automatically publishes to PyPI using trusted publishing