Skip to content
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: 14 additions & 14 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: pre-commit
# name: pre-commit

on:
pull_request:
push:
branches: [main]
# on:
# pull_request:
# push:
# branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: pre-commit/action@v3.0.1
# jobs:
# pre-commit:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with:
# python-version: '3.12'
# - uses: pre-commit/action@v3.0.1
104 changes: 76 additions & 28 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,101 @@
name: Publish to PyPI
name: Publish to PyPI and GitHub Pages

on:
push:
tags: "*"

jobs:
build:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
permissions:
id-token: write
repository-projects: write
contents: write
pages: write

steps:
- uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv tox
uv sync
- name: Install tox
run: uv tool install tox --with tox-uv

- name: Test
run: |
tox -e default
run: tox -e default

- name: Build Project
run: |
tox -e build
run: tox -e build

# This uses the trusted publisher workflow so no token is required.
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

build-docs:
Comment on lines +9 to +39
name: Build Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install tox
run: uv tool install tox --with tox-uv

- name: Build docs
run: |
tox -e docs
run: tox -e docs

- name: Add .nojekyll
run: touch ./docs/_build/html/.nojekyll

- run: touch ./docs/_build/html/.nojekyll
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/_build/html

- name: GH Pages Deployment
uses: JamesIves/github-pages-deploy-action@v4
publish-pypi:
Comment on lines +40 to +69
name: Publish to PyPI
needs: build-and-test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/{{ project_name|replace('-', '_') }}
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: ./docs/_build/html
clean: true # Automatically remove deleted files from the deploy branch
name: python-package-distributions
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

deploy-pages:
name: Deploy GitHub Pages
needs: build-docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
18 changes: 10 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
test:
strategy:
matrix:
python: ["3.12", "3.13", "3.14"]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
platform:
- ubuntu-latest
- macos-latest
Expand All @@ -38,16 +38,18 @@
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
id: setup-python
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv tox
uv sync
- name: Install tox
run: uv tool install tox --with tox-uv

- name: Run tests
run: |
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## 0.1.0 - 0.1.1

### Added
- Initial project scaffolding.
- Switch to copier and modify the templates
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ pip install hatchit

## Quickstart Tutorial

To create a brand new repository, simply run the `hatchit` CLI command:
To create a brand new repository, you can use the `hatchit` CLI command:

```bash
hatchit my-awesome-package --description "A robust new tool" --license MIT
```

Alternatively, since `hatchit` is a 100% compatible Copier template, you can use `copier` directly to render the project!

```bash
pip install copier
copier copy https://github.com/biocpy/hatchit my-awesome-package
```

or to programmatically create a project,

```py
Expand All @@ -29,14 +36,17 @@ create_hatchit_repository(project_path = "my-awesome-package", description = "ne

This will generate the project in the `my-awesome-package` directory and initialize a fresh Git repository.

## After setup
## What's Next? (After Setup Checklist)

Now that your project is perfectly scaffolded, there are just a few quick things you'll want to configure to get the full automated experience working for you:

- The GitHub workflows use "trusted publisher workflow" to publish packages to PyPI. Read more instructions [here](https://docs.pypi.org/trusted-publishers/).
- Install [tox](https://tox.wiki/en/4.23.2/) to handle package tasks. GitHub Actions relies on the tox configuration to test, generate documentation, and publish packages.
- (Optional) Enable the [pre-commit.ci](https://pre-commit.ci/) bot for your repository.
- (Optional) Install [ruff](https://docs.astral.sh/ruff/) for code formatting.
- (Optional) Setup [codecov](https://about.codecov.io/) for coverage reports.
1. **Update `pyproject.toml` keywords**: We've added a few placeholder keywords (like `"TODO"`, `"FIXME"`) to your `pyproject.toml`. Swap those out with relevant keywords for your package to make it more discoverable on PyPI!
2. **Setup PyPI Trusted Publishing**: We use GitHub Actions for publishing. You don't need any secrets! Instead, head over to PyPI, create a "Pending Publisher", and link it to your GitHub repository. [Read more here](https://docs.pypi.org/trusted-publishers/).
3. **Configure Codecov (Optional)**: If you want test coverage reports, head to [Codecov](https://about.codecov.io/), link your repo, grab your token, and add it as a `CODECOV_TOKEN` secret in your GitHub repository.
4. **Activate pre-commit.ci (Optional)**: If you want automated PRs keeping your code perfectly formatted, enable the [pre-commit.ci](https://pre-commit.ci/) bot on your repo.
5. **Enable GitHub Pages (Optional)**: The publishing workflow automatically builds your Sphinx docs. To serve them, go to your repository settings, navigate to "Pages", and select **GitHub Actions** as the "Source". The deployment workflow will automatically publish the built artifact to your site!

That's it! You're ready to start writing code.

## Development Process

Expand Down
49 changes: 49 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
_subdirectory: template

# Project Info
project_name:
type: str
help: Name of the project (e.g. my-awesome-package)
python_package_name:
type: str
default: "{{ project_name|replace('-', '_') }}"
when: false
description:
type: str
default: "Add a short description here!"
help: Short description of the project
license:
type: str
default: MIT
help: License for the project
choices:
"Permissive - MIT": "MIT"
"Permissive - BSD-3-Clause": "BSD-3-Clause"
"Permissive - Apache-2.0": "Apache-2.0"
"Copyleft - GPL-3.0": "GPL-3.0-only"
copyright_year:
type: str
default: "{{ '%Y' | strftime }}"
help: "What is the starting year of the project? Used in copyright statements."

# Author Info
author_name:
type: str
default: "First Author"
help: Name of the author
author_email:
type: str
default: "first.author@example.com"
help: Email of the author
github_username:
type: str
default: "YOUR_ORG_OR_USERNAME"
help: GitHub Organization or Username

# Tasks to run after generation
_tasks:
- "uv lock"
- "git init"
- "git add ."
# Use ignore_errors because git commit might fail if git user isn't configured, or we can just run it.
- "git commit -m 'chore: initial setup' || true"
29 changes: 0 additions & 29 deletions docs/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions docs/api/modules.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
hatchit
=======
src
===

.. toctree::
:maxdepth: 4
Expand Down
Loading
Loading