Metadata-Version: 2.4
Name: leanpub-multi-action
Version: 2.0.1
Summary: GitHub Actions for Leanpub.com
Project-URL: Homepage, https://github.com/lykinsbd/leanpub-multi-action
Project-URL: Repository, https://github.com/lykinsbd/leanpub-multi-action
Project-URL: Issues, https://github.com/lykinsbd/leanpub-multi-action/issues
Author-email: Brett Lykins <lykinsbd@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.13
Requires-Dist: click>=8
Requires-Dist: requests>=2
Description-Content-Type: text/markdown

# Leanpub Multi Action

[![CI](https://github.com/lykinsbd/leanpub-multi-action/actions/workflows/tests.yml/badge.svg?branch=dev)](https://github.com/lykinsbd/leanpub-multi-action/actions/workflows/tests.yml)

A GitHub Action to interact with the [Leanpub API](https://leanpub.com/help/api).
Preview, publish, and check job status for your Leanpub books — directly from your GitHub workflows.

## Quick Start

```yaml
- name: "Preview Book"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "preview"
```

## Inputs

| Name | Required | Default | Description |
|------|----------|---------|-------------|
| `leanpub-api-key` | Yes | — | Leanpub API key (requires a [Pro plan](https://leanpub.com/help/api)). Store as a [GitHub Secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions). |
| `leanpub-book-slug` | Yes | — | Book slug — the path component after `https://leanpub.com/`. |
| `action` | Yes | — | Action to perform: `preview`, `publish`, or `check-status`. |
| `email-readers` | No | `"false"` | Email readers about a new publish. Only used with `publish`. |
| `release-notes` | No | — | Release notes for the publish. Only used with `publish`. |
| `subset` | No | `"false"` | Preview only the files listed in `Subset.txt`. Only used with `preview`. |
| `single-file` | No | — | Path to a Markdown file for single-file preview. Only used with `preview`. |

## Examples

### Full preview on push

```yaml
---
name: "Preview on Push"

"on":
  push:
    branches: ["preview"]

jobs:
  preview:
    runs-on: "ubuntu-latest"
    steps:
      - name: "Preview Book"
        uses: "lykinsbd/leanpub-multi-action@v2"
        with:
          leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
          leanpub-book-slug: "mygreatbook"
          action: "preview"
```

### Subset preview

Preview only the files listed in your book's `Subset.txt`:

```yaml
- name: "Subset Preview"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "preview"
    subset: "true"
```

### Single-file preview

Preview a single Markdown file without modifying `Subset.txt`.
The output PDF is saved as `{slug}-single-file.pdf` in your Dropbox previews folder.

```yaml
- name: "Checkout"
  uses: "actions/checkout@v4"
- name: "Single File Preview"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "preview"
    single-file: "manuscript/chapter-05.md"
```

### Publish with release notes

```yaml
- name: "Publish"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "publish"
    email-readers: "true"
    release-notes: "Chapter 5 added"
```

### Check job status

```yaml
- name: "Check Status"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "check-status"
```

## CLI Usage

The action also ships as a standalone CLI tool called `lma`.

```bash
uv tool install leanpub-multi-action
```

or with pip:

```bash
pip install leanpub-multi-action
```

```bash
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook preview
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook preview --subset
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook preview --single-file chapter.md
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook publish --email-readers --release-notes "v2"
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook check-status
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.

## License

[MIT](LICENSE)
