> For the complete documentation index, see [llms.txt](https://pubrelease.onepub.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pubrelease.onepub.dev/hooks.md).

# Hooks

Pub Release supports the concept of pre and post release hooks.

A hook is simply a script that is run before or after the release is pushed to pub.dev.

Hooks live in the following directories:

* `<project root>`/tool/pre\_release\_hook
* `<project root>`/tool/post\_release\_hook

Where the `project root` is the directory where your pubspec.yaml lives.

You can include any number of scripts in each of these directories and they will be run in alphanumerical order.

When your hook is called it will be passed the new version as a cli argument:

```bash
my_hook.dart 1.0.0
```

### dry-run

If the `--dry-run` flag is passed to the `pub_release` command then a `--dry-run` flag will be passed on the command line to the hook.

If the `--dry-run` flag is passed than your hook should suppress any actions that permanently modify the project.

```bash
my_hook.dart --dry-run 1.0.0
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pubrelease.onepub.dev/hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
