# Publishing Packages

## Permissions

Only Uploaders may publish a package. Each edition of OnePub defines an Uploader differently.

{% tabs %}
{% tab title="Free/Pro" %}
As all Members are Uploaders any Member can create a new package by running 'dart | flutter pub publish'.

All packages are associated with the Default Team and as such all Members have access to the package.
{% endtab %}

{% tab title="Team" %}
As all Members are Uploaders any Member can create a new package by running 'dart | flutter pub publish'.

To share a package it must be associated with a Team which only Team Leaders and/or Administrators may do.
{% endtab %}

{% tab title="Enterprise" %}
As all Members are Uploaders any Member can create a new package by running 'dart | flutter pub publish'.

To share a package it must be associated with a Team which only Team Leaders and/or Administrators may do.
{% endtab %}
{% endtabs %}

{% hint style="success" %}
The secret to successfully publishing a package is.... good documentation.

Add a readme.md, take some time to document your public API and throw in some examples.
{% endhint %}

## Security

The largest risk you face is accidentally publishing your package to pub.dev.

## Publishing

If this is your first time publishing a package then you might find our blog article on publishing useful:

* [Publish your first package](https://onepub.dev/Blog?id=zuhnoflygz)

### Mark package as private

To prepare a package for uploading to OnePub you must mark it as a private package.&#x20;

Run the `onepub pub private` command:

```bash
onepub login # if you are not already authed
onepub pub private 
```

This has the effect of adding a `publish_to` key to your `pubspec.yaml` file. The `publish_to` instructs dart to publish you package to OnePub rather than pub.dev.

And now publish your package to OnePub:

```
dart pub publish
```

{% hint style="warning" %}
Note: you can add the publish\_to key manually by following [the hard way](https://docs.onepub.dev/guides/publishing-packages/the-hard-way) instructions.
{% endhint %}

### Public Packages

Some of your team members may need to publish both private and public packages.

All **public** packages should be published directly to pub.dev using the standard dart tooling/processes.

**Public packages** you upload to pub.dev will be cached on onepub.dev within a few minutes of you publishing to pub.dev, so you can easily find these packages on OnePub as well as pub.dev

## Teams

If your OnePub organisation has multiple teams (you need the Team or Enterprise license) then are some additional steps required when uploading a package.

The core issue is that you need to nominate the team the package belongs to before uploading the package.

A package may be associated with multiple teams.

To associate a package with a Team

* Navigate to My OnePub | [Managed Packages](https://onepub.dev/DartPackageList)
* Create a new package
* Enter the package name and description.
* On the Teams tab, select each of the teams the package is associated with.
* Save the new package.

You can now publish your package from the CLI as per the normal process.


---

# Agent Instructions: 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://docs.onepub.dev/guides/publishing-packages.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.
