Packages

Dependency Management

Once built, Taxi projects can be packaged and published to a repository to allow other projects to depend on them.

A package contains every file in the project’s directory that git tracks. Untracked and ignored files are left out.

​
Adding dependencies

Dependencies are defined in the taxi.conf project, in the dependencies section. Here’s an example:

// Create a project in the acme organisation named "depends-on-sample"
name: acme/depends-on-sample
version: 0.3.0
sourceRoot: src/

dependencies: {
    // Depends on a project in the "acme" organisation called "sample", version 0.3.0
   "org.acme/sample": 0.3.0

    // Fetch from a github repository, at a specific branch / tag
    "com.orbitalhq/core" : "github:orbitalapi/orbital-core-taxi#0.34.0"
   
    // Fetch from a gitlab repository (at https://gitlab.com) on the default branch
    "org.test/dependencyA" : "gitlab:taxi-lang/test-project-a"

   // Depends on a project from git
   "org.acme/another-project" : "https://someGitProvider.com/taxi-lang/another-project.git"

   // Depends on a project from git, at a specific branch / tag
   "org.acme/project-3" : "https://someGitProvider.com/taxi-lang/project-3.git#1.2.0"
}

When running a taxi build command, the taxi-cli will first ensure that all dependent projects have been downloaded, and are present in the local cache.

Dependencies are fetched either from git, or from a taxihub listed in the repositories section of your taxi.conf.

For more details on how to define dependencies, and configure repositories to download them from, see here.

If you're editing your taxi.conf file in VSCode using our plugin, saving changes to your taxi.conf will trigger the download of any dependencies as soon as you save the file.

​
Sharing projects using Git

You can pull projects directly from a git repository, without a taxihub.

Declare them as follows:

// Create a project in the acme organisation named "depends-on-sample"
name: acme/depends-on-sample
version: 0.3.0
sourceRoot: src/

dependencies: {
   // Depends on a project from git
   "org.acme/another-project" : "https://gitlab.com/taxi-lang/another-project.git"

   // Depends on a project from git, at a specific branch / tag
   "org.acme/project-3" : "https://gitlab.com/taxi-lang/project-3.git#1.2.0"
}

If working exclusively with git repos, you don’t need to declare a repositories section.

​
Github / Gitlab shorthand

To use dependencies from github.com or gitlab.com, you can use the format github:org/project (or github:org/project#tag)

For example:

dependencies: {
    // Fetch from a github repository, at a specific branch / tag
    "com.orbitalhq/core" : "github:orbitalapi/orbital-core-taxi#0.34.0"
   
    // Fetch from a gitlab repository (at https://gitlab.com) on the default branch
    "org.test/dependencyA" : "gitlab:taxi-lang/test-project-a"
}

​
Authenticating to Git repos

To provide authentication credentials, use a Username + Personal Authentication Token (supported in Github and Gitlab).

For example:

dependencies: {
    "com.orbitalhq/core" : "https://alexhamilton:[email protected]/taxi-conf/reynolds-pamphlet.git"
}

HOCON supports env variable substitution, so you can also move sensitive credentials into an env variable:

dependencies: {
    // Note the variable is outside of quotes.
    "com.orbitalhq/core" : "https://"${GH_PAT}"@github.com/taxi-conf/reynolds-pamphlet.git"
}

However, be careful of gotcha’s with variable substitution in HOCON - see more information in this issue in the HOCON library

​
Sharing projects with taxihub

A taxihub is a registry of Taxi projects. Projects published to a taxihub can be used as dependencies by other projects.

​
Using dependencies from a taxihub

List the taxihub in the repositories section of your taxi.conf, then add dependencies by name and version:

repositories: [
   { name: "taxihub", url: "https://hub.example.com", type: "taxihub" }
]

dependencies: {
   "acme/orders": 1.2.0
}

type can be left out, as taxihub is the default.

When you build, the Taxi CLI downloads each dependency from the taxihub, and keeps a copy in its local cache.

​
Publishing to a taxihub

taxi publish publishes a version of your project to a taxihub.

Nothing is uploaded. Instead, taxi publish tells taxihub “version 1.2.0 of acme/orders is the tag v1.2.0 in this git repository”. taxihub then clones that tag itself, checks it, compiles it, and records it. So the project must be in a git repository that taxihub can clone, and the version must be tagged.

​
1. Say where to publish

Add publishToRepository to your taxi.conf:

name: acme/orders
version: 1.2.0

publishToRepository: {
   name: taxihub                      // used to find your token in `credentials`
   url: "https://hub.example.com"
}

type can be left out, as taxihub is the default.

taxihub has some rules for the projects it accepts. taxi publish checks these before sending anything, with taxihub’s own rules:

  • The name is organisation/name, in lower-case letters, digits and - (the organisation may also contain .), with up to 64 characters in each part.
  • The version is a semantic version, like 1.2.0 or 1.2.0-rc.1.
  • The repository URL is an https URL that taxihub can reach.

taxihub checks the rest when it clones the tag, and reports it as the reason publishing failed:

  • There are no plugins, and no pluginSettings.
  • Dependencies are versions or ranges of packages on the hub (like 1.0.0 or ^1.0.0), not git URLs or github: / gitlab: shorthands.
  • There are no git submodules in the project.

​
2. Get a token

Publishing needs a taxihub token (thp_…) that is allowed to publish the package, for example one scoped to publish:acme/*. Create one on your account page on the taxihub (https://hub.example.com/account). The first time you publish to an organisation, claim its namespace on the hub too.

taxi publish looks for the token in this order, and uses the first it finds:

  1. The TAXIHUB_TOKEN environment variable.
  2. A CI job’s identity token, which taxihub swaps for a short-lived token. See Publishing from CI.
  3. A credentials entry whose repositoryName matches the name of publishToRepository.

Keep the credentials entry in ~/.taxi/taxi.conf, in your home directory, so the token stays out of your project’s repository:

credentials: [
   { repositoryName: "taxihub", token: "thp_…" }
]

taxi publish never prints the token, even with --debug.

Older versions of Taxi used a username and password in a credentials entry. A credentials entry now needs a token.

​
3. Tag the version and push it

Commit your changes, then tag the commit with the version from taxi.conf, and push the tag:

git tag v1.2.0
git push origin v1.2.0

taxi publish looks for a tag called v<version> or <version> (in that order) on the current commit. To publish a tag with another name, use --tag. Either way, the tag must be on the current commit. That way, the files you have checked out are the files taxihub clones.

In a CI job started for a tag, the job’s tag is used as if it had been passed with --tag. This is CI_COMMIT_TAG in GitLab, and GITHUB_REF_NAME (when GITHUB_REF_TYPE is tag) in GitHub Actions.

​
4. Publish

Run taxi publish in the project’s directory:

$ taxi publish
Compilation succeeded
Publishing acme/orders 1.2.0 to https://hub.example.com
  repository  https://github.com/acme/orders
  tag         v1.2.0 (commit 9f3c1e2)
  path        .
✓ clone
✓ dependencies
✓ compile
✓ commit
Published acme/orders 1.2.0
  https://hub.example.com/p/acme/orders/1.2.0

Before it calls taxihub, taxi publish:

  • compiles the project, as taxi build does
  • reads the URL of the repository from the origin remote, in its https form ([email protected]:acme/orders.git becomes https://github.com/acme/orders)
  • checks no tracked file in the project’s directory has uncommitted changes. Untracked files, and changes elsewhere in the repository, are ignored

It doesn’t check the tag has been pushed: taxihub clones the tag, and says so if it isn’t there, or is on a different commit.

Then it waits for taxihub to finish, and prints each step as taxihub finishes it. The project can be in a subdirectory of the repository (path is the directory holding taxi.conf).

Running taxi publish again for a version that’s already published from the same commit isn’t an error. It prints Already published.

The command exits with 0 when the version is published (or was already), or a dry run passed, and 1 when anything fails.

​
Options

OptionUsage
--dry-runAsk taxihub to run every check, but record nothing
--tag <name>Publish this tag, instead of v<version> or <version>. It must be on the current commit
--repository <url>The https URL taxihub clones, instead of the origin remote
--no-waitDon’t wait for taxihub to finish. Prints the job’s id and the package’s page instead
--timeout <time>How long to wait for taxihub: a number of seconds, minutes or hours, eg: 90s, 10m or 1h. The default is 5m
--skip-local-buildDon’t compile the project before publishing

--dry-run and --no-wait can’t be used together.

If taxi publish stops waiting (because of --timeout), taxihub carries on with the job. taxi publish prints the job’s id and the package’s page on the hub, so you can follow it.

If a publish of the same version is already running on taxihub, taxi publish waits for it instead of starting another. If that one is a dry run and yours isn’t (or the other way round), it stops, and asks you to run it again once the other has finished.

​
When publishing fails

taxi publish says what went wrong, and what to do about it. The common failures are:

MessageWhat it means
There’s no tag v1.2.0 or 1.2.0 in this git repositoryTag the commit and push the tag, as in step 3
The tag v1.2.0 is on commit …, but the current commit is …Check out the tagged commit, or tag the current commit with a new version
There are uncommitted changes in the projectCommit (and tag) them, or stash them
No taxihub token was foundSet TAXIHUB_TOKEN, add a credentials entry (as in step 2), or publish from CI
taxihub refused the request (HTTP 401)The token is wrong or has expired. Create a new one
taxihub refused the request (HTTP 403)Claim the namespace on the hub, or use a token scoped to the package
… already exists at commit …A published version can’t be replaced. Publish a new version
COMPILE_FAILEDThe compiler’s messages follow, as taxi build prints them
TAG_NOT_FOUNDThe tag hasn’t been pushed to the repository taxihub clones
TAG_SHA_MISMATCHThe tag was moved after it was pushed. Fetch the tags, and check out the tag that was pushed

For any other failure, taxi publish prints the code and message taxihub sent.

​
Publishing from CI

A CI job can publish without a stored token. The CI service gives each job an identity token, which says which repository, tag and workflow the job is running for. taxihub swaps it for a token that can publish one package, and lasts 15 minutes.

taxihub only does this for a trusted publisher: a rule, set on the package, that says which CI jobs may publish it. So there’s no token to create, store in CI, or rotate.

​
1. Add a trusted publisher on taxihub

Open the package’s page on the hub (https://hub.example.com/p/acme/orders), and add a trusted publisher. Only owners of the package’s namespace can do this.

For GitLab CI:

SettingValue
Issuerhttps://gitlab.com, or the URL of your GitLab
project_pathYour project, eg: acme/orders
ref_pathrefs/tags/*
ref_protectedtrue

ref_protected means only protected tags can publish. Protect your release tags (eg: v*) in the project’s settings, under Repository > Protected tags.

For GitHub Actions:

SettingValue
Issuerhttps://token.actions.githubusercontent.com
repositoryYour repository, eg: acme/orders
workflow_refThe workflow file, at a tag, eg: acme/orders/.github/workflows/publish.yml@refs/tags/*

A claim’s value can contain *. Everything else must match exactly.

The hub must also trust the issuer (GitLab or GitHub). This is set up once for the whole hub, by its operators.

​
2. Run taxi publish in the job

taxi publish finds the identity token itself:

  • In GitLab CI, it reads the TAXIHUB_ID_TOKEN variable. Declare it under id_tokens in the job.
  • In GitHub Actions, it asks GitHub for a token. The job needs the id-token: write permission.

The token is for an audience, which must be the one taxihub expects. This is taxihub, unless the hub’s operators changed it. In GitLab, set it with aud. In GitHub Actions, set the TAXIHUB_AUDIENCE environment variable if it isn’t taxihub.

When the token is swapped, taxi publish prints:

Signed in to https://hub.example.com as a trusted publisher (GitLab CI)

If taxihub won’t swap the token, taxi publish fails, and shows what taxihub said. It doesn’t fall back to a credentials entry (it says so, when there is one). TAXIHUB_TOKEN is still used first if it’s set, so setting it overrides both.

A job started for a tag publishes that tag, as described in step 3. taxihub won’t publish from a GitHub workflow run for a pull request.

The jobs below install taxi with the install script. It installs the native binary, which runs on Linux x86_64 with glibc (not Alpine). It needs curl (or wget) and unzip.

The checkout doesn't need the whole history. taxi publish only reads the tagged commit, so the default shallow checkouts in GitLab and GitHub work.

​
GitLab CI

Add this job to .gitlab-ci.yml. It runs when a tag starting with v is pushed:

publish-to-taxihub:
  rules:
    - if: $CI_COMMIT_TAG =~ /^v/
  image: ubuntu:24.04
  id_tokens:
    TAXIHUB_ID_TOKEN:
      aud: taxihub
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends curl ca-certificates unzip
    - curl -fsSL https://taxilang.org/install.sh | sh
    - export PATH="$HOME/.taxi/bin:$PATH"
  script:
    - taxi publish

​
GitHub Actions

Add this workflow as .github/workflows/publish.yml. It runs when a tag starting with v is pushed:

name: Publish to taxihub

on:
  push:
    tags:
      - "v*"

permissions:
  contents: read
  id-token: write

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install taxi
        run: |
          curl -fsSL https://taxilang.org/install.sh | sh
          echo "$HOME/.taxi/bin" >> "$GITHUB_PATH"
      - name: Publish
        run: taxi publish

The workflow_ref of the trusted publisher names this file: acme/orders/.github/workflows/publish.yml@refs/tags/*.

​
When publishing from CI fails

taxi publish shows what taxihub said, with a hint:

taxihub refused the request withWhat it means
HTTP 401taxihub doesn’t accept identity tokens from this CI service, or the token is for another audience. Check aud in GitLab, or TAXIHUB_AUDIENCE in GitHub Actions
HTTP 403No trusted publisher of the package matches the job (or the job is for a pull request). Check the trusted publishers, as in step 1
HTTP 429Too many requests. Try again later
Previous
Taxi projects
Next
Taxi CLI