# Publish from a project

> Set up a project once, then publish it from your computer with one command.

Source: https://docs.telesphorepo.com/publish-from-a-project/

One person sets up each project once. After that, everyone publishes with `telesphorepo publish`.

To publish from GitHub Actions or Jenkins, set up the project here first. Then go on to [Publish from CI](/publish-from-ci/).

## Set up the project

Does the project folder hold `telesphorepo.toml` already? Then someone set it up. Pull the latest commit, and go on to [Publish](#publish).

1. Open your repository in the web UI, then the **Publish to this repository** tab.

2. Click **Set up a project**, and confirm with your second factor.

3. Open a terminal in the project folder. Paste the setup line from the page, then press Enter.

   - macOS or Linux

     ```sh
     curl -fsSL https://your-server/install.sh | sh -s -- setup 'https://your-server/#/setup/trsu_...'
     ```

   - Windows

     ```powershell
     & ([scriptblock]::Create((irm https://your-server/install.ps1))) setup 'https://your-server/#/setup/trsu_...'
     ```

   - The CLI is installed

     ```sh
     telesphorepo setup 'https://your-server/#/setup/trsu_...'
     ```

4. When the CLI asks for a CI file, choose **No CI file**.

   To publish from CI too, choose **GitHub Actions**, **Jenkinsfile** or **Jenkins freestyle job**. Then follow [Publish from CI](/publish-from-ci/).

Done when the CLI prints `publishing to your-repo` with the format and your username.

The line installs the CLI, approves this computer and writes `telesphorepo.toml`. It asks before it changes a file.

## Commit the files

Commit `telesphorepo.toml` and push it. Add the CI file too, if the CLI wrote one. The files hold no secrets.

```sh
git add telesphorepo.toml
git commit -m "Publish to Telesphorepo"
git push
```

Your teammates and CI read this file, so they publish to the same repository.

## Publish

1. In the project folder, run this.

   ```sh
   telesphorepo publish
   ```

2. The first time, the CLI prints a link and a code. Open the link, then click **Approve device**.

Done when your build tool says the publish worked.

The CLI runs the build tool of the project for you, and prints the command first. To see that command without a publish, run `telesphorepo status`.

For a Debian or raw repository, name the files:

```sh
telesphorepo publish app-1.2.0.tar.gz
```

## Push Docker images

Do this once on each computer.

1. On a Docker repository, [set up the project](#set-up-the-project) as above.

2. When the CLI asks to add the credential helper to `~/.docker/config.json`, type `y`.

3. Tag the image with your server’s host name and the repository name, then push it.

   ```sh
   docker push your-server/your-repo/app:1.0
   ```

You run no `docker login`. Docker, Podman, Helm and ORAS get a token from the helper at each push.

## Set it up by hand

Use this when you cannot run the setup line.

1. [Install the CLI](/install-cli/).

2. Approve this computer. Open the link that the CLI prints, sign in, and approve the code.

   ```sh
   telesphorepo login https://your-server
   ```

3. Create `telesphorepo.toml` in the project folder, and commit it.

   ```toml title="telesphorepo.toml"
   server = "https://your-server"
   repo = "your-repo"
   ```

Some repositories need more keys, such as `path` for raw. See [telesphorepo.toml](/commands-and-settings/#telesphorepotoml).

To publish with the build tool’s own command instead, open **Set it up by hand** on the **Publish to this repository** tab.

## If something goes wrong

The CLI does not find a project

Run the line in the folder that holds the project file, such as `pom.xml` or `package.json`. The CLI names the files that it looks for.

`no telesphorepo.toml in this folder or above`

[Set up the project](#set-up-the-project), or pull the latest commit.

The setup line was used or ended

A line works once, for 10 minutes. Click **Set up a project** again for a new line.

The CLI says that git ignores `telesphorepo.toml`

Then CI and your teammates do not get the file. Remove the line that the warning names from `.gitignore`, or run `git add -f telesphorepo.toml`.

No browser page opens, or it asks for two-step verification

Copy the address from the terminal, and open it yourself.

If the page asks for two-step verification, click **Set up two-step verification**. Add your phone app, then approve.

The server refused the device

Run `telesphorepo login https://your-server`, and approve again. An approval lasts 90 days, unless someone removes the device.

The CLI says that a tool is not on the PATH

Install the build tool of the project, such as `pnpm`, `poetry` or `dotnet`. Then publish again.

403 when you publish

You cannot publish to this repository yet. Ask your server admin for **Publish**.

409 when you publish

That version is on the server already. Raise the version, then publish again.

You want to take a version back

Open the repository’s **Files** tab, and delete the files of that version. You need **Delete files** on the repository.

The CLI says that it needs a newer CLI or a newer server

For a newer CLI, press Enter to update, or run `telesphorepo update`. For a newer server, ask your server admin.
