---
title: Releasing and pull requests
description: Changelog generation, PyPI and GitHub releases, and quick pull requests.
order: 2
---
[`ship_release`](release.md#ship_release) discovers project metadata once, prepares the release, and branches once at publication. Pure-Python packages (including notebook-authored packages) build and publish locally with `uv build --clear` and `uv publish`, create the GitHub release, and push a `[skip ci]` version bump. Tag-published projects (Rust/maturin, Zig, npm, pure-Rust crates, or `release = "tag"`) push an annotated `vX.Y.Z` tag for CI publication, bump the version, and return immediately without polling CI.

```bash
ship-release
ship-release --yes --no-editor
```

GitHub commands resolve authentication in order: `--token` / `token`, `$FASTSHIP_TOKEN`, a `./token` file (checked in the project root, then the current directory), and `$GITHUB_TOKEN`. PyPI uploads use `UV_PUBLISH_TOKEN` (or `UV_PUBLISH_USERNAME`/`UV_PUBLISH_PASSWORD`) when set, falling back to `~/.pypirc` for `[pypi]` unless `UV_PUBLISH_URL` or `UV_PUBLISH_INDEX` selects an alternate destination. Commands raise `CliError` for missing credentials or invalid project state, `ValueError` for invalid config or `version-files`, and `APIError` or `subprocess.CalledProcessError` when GitHub API or build commands fail.

## update\_changelog

```python
def update_changelog(
    txt:str, # Existing `CHANGELOG.md` contents
    ver:str, # Release version heading to insert or replace
    notes:str, # Formatted Markdown notes starting with `## <ver>`
    marker:str='<!-- do not remove -->\n', # Anchor comment after which release sections are inserted
)->str:
```

*Insert `notes` into changelog `txt` after `marker`, replacing any existing section for `ver`.*

```python
from fastcore.test import test_eq, test_fail
log = "# Release notes\n\n<!-- do not remove -->\n\n## 0.0.1\n\n- First release\n"
test_eq(update_changelog(CHANGELOG_TMPL, '0.0.1', '\n## 0.0.1\n\n- First release'), log)
upd = update_changelog(log, '0.0.2', '\n## 0.0.2\n\n- New feature')
assert upd.index('## 0.0.2') < upd.index('## 0.0.1')
assert '- New feature\n\n\n## 0.0.1' in upd
test_fail(lambda: update_changelog("# Release notes\n", '0.0.1', '\n## 0.0.1\n\n- First release'), contains='do not remove', exc=ValueError)
upd2 = update_changelog(upd, '0.0.2', '\n## 0.0.2\n\n- Improved feature\n')
test_eq(upd2, update_changelog(log, '0.0.2', '\n## 0.0.2\n\n- Improved feature\n'))
test_eq(upd2.count('## 0.0.2'), 1)
assert 'New feature' not in upd2 and '## 0.0.1' in upd2
```

## Releasing

Run the full release workflow, individual changelog/PyPI/GitHub stages, or squash-merge a quick PR.

### Release

```python
def Release(
    owner:str=None, # GitHub owner or organization (inferred from `repo` or git `origin` when omitted)
    repo:str=None, # Repository name or `"OWNER/REPO"` slug
    token:str=None, # GitHub token (else `$FASTSHIP_TOKEN`, `./token`, or `$GITHUB_TOKEN`)
    cfg:fastship.config.ShipConfig | None=None, # Explicit `ShipConfig` (loads via `get_config()` when omitted)
):
```

*Create `CHANGELOG.md` entries and GitHub releases for a `fastship` project.*

Groups closed issues and pull requests under the fixed `breaking`, `enhancement`, and `bug` headings in `DEFAULT_LABEL_GROUPS`. Changes working directory to `cfg.root` during initialization.

#### Release.changelog

```python
async def changelog(
    debug:bool=False, # Return proposed release notes instead of updating `CHANGELOG.md`
):
```

*Generate release notes from closed labeled GitHub issues since the latest GitHub release.*

#### Release.latest\_notes

```python
def latest_notes()->str:
```

*Return the latest `## <version>` entry from `CHANGELOG.md`.*

#### Release.release

```python
async def release()->Release:
```

*Tag and create a GitHub release for `cfg.version` at the current pushed commit.*

### ship\_release

```python
async def ship_release(
    token:str=None, # GitHub token (else `$FASTSHIP_TOKEN`, `./token`, or `$GITHUB_TOKEN`)
    repo:str=None, # Override repo (`"OWNER/REPO"`)
    no_changelog:bool=False, # Skip changelog generation (local release flow only)
    no_editor:bool=False, # Skip opening `CHANGELOG.md` in `$EDITOR` (local release flow only)
    yes:bool=False, # Skip confirmation prompt (local release flow; tag flows never prompt)
    wheel_only:bool=False, # Build only a wheel without an sdist (local release flow)
    verbose:bool=False, # Pass `--verbose` to `uv publish`
):
```

*Run the release workflow for the current project, then bump and push the version.*

- Local Python packages (including notebook-authored packages): updates `CHANGELOG.md`, refreshes tracked exports, builds with `uv build --clear`, commits and pushes, creates the GitHub release, publishes via `uv publish`, and commits a `[skip ci]` version bump.
- Package-less projects ([`gh_only`](config.md#gh_only)): creates a GitHub release with auto-generated notes and bumps the static version.
- Tag-published projects (Rust/maturin, Zig, npm, pure-Rust crates, or `release = "tag"`): verifies a clean git tree and `version-files`, refreshes tracked exports when applicable, pushes an annotated `v<version>` tag for CI, and commits a `[skip ci]` version bump.

### ship\_changelog

```python
async def ship_changelog(
    token:str=None, # GitHub token (else `$FASTSHIP_TOKEN`, `./token`, or `$GITHUB_TOKEN`)
    repo:str=None, # Override repo (`"OWNER/REPO"`)
    debug:bool=False, # Print proposed notes without modifying `CHANGELOG.md`
):
```

*Create or update `CHANGELOG.md` from closed labeled GitHub issues since the last release.*

### ship\_pypi

```python
def ship_pypi(
    quiet:bool=False, # Reduce `uv build` and `uv publish` output verbosity
    wheel_only:bool=False, # Build only a wheel without an sdist (also honored via `wheel-only`)
    verbose:bool=False, # Pass `--verbose` to `uv publish`
):
```

*Build distributions with `uv build --clear` and upload with `uv publish` without bumping the version.*

### ship\_release\_gh

```python
async def ship_release_gh(
    token:str=None, # GitHub token (else `$FASTSHIP_TOKEN`, `./token`, or `$GITHUB_TOKEN`)
    repo:str=None, # Override repo (`"OWNER/REPO"`)
    no_changelog:bool=False, # Skip changelog generation (assumes `CHANGELOG.md` is ready)
    no_editor:bool=False, # Skip opening `CHANGELOG.md` in `$EDITOR` (defaults to `nano`)
    yes:bool=False, # Release without prompting for confirmation
):
```

*Update `CHANGELOG.md`, optionally edit it, commit and push tracked changes, and create a GitHub release.*

### ship\_pr

```python
async def ship_pr(
    title:str, # PR title (also used as commit message for uncommitted changes and squash title)
    branch:str=None, # Branch name to create (defaults to `pr/<slug-from-title>`)
    label:str='enhancement', # GitHub label added to the PR
    body:str='', # PR body text, path to an existing file containing it, or `"-"` to read stdin
    token:str=None, # GitHub token (else `$FASTSHIP_TOKEN`, `./token`, or `$GITHUB_TOKEN`)
    repo:str=None, # Override repo (`"OWNER/REPO"`)
    path:str='.', # Repository directory (defaults to current working directory)
):
```

*Create a pull request from uncommitted or unpushed work, squash-merge it, and reset the default branch.*

Run from the default branch with no unpulled commits on `origin`. Creates a branch, commits tracked changes, pushes, opens and labels the PR, and squash-merges it. Afterward it deletes both remote and local PR branches and resets the default branch to `origin/<default>`.

```bash
ship-pr "Add new feature"
ship-pr "Fix bug" --label bug --body notes.md
```
