librarian

module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: Apache-2.0

README

Librarian CLI

Go Reference codecov

This repository contains code for a unified command line tool for Google Cloud SDK client library configuration, generation and releasing.

See CONTRIBUTING.md for a guide to contributing to this repository, and the doc/ folder for more detailed project documentation.

The Librarian project supports the Google Cloud SDK ecosystem, and we do not expect it to be of use to external users. That is not intended to discourage anyone from reading the code and documentation; it's only to set expectations. (For example, we're unlikely to accept feature requests for external use cases.)

Installation

Install Go and make sure you have you have the following in your PATH:

export PATH="$(go env GOPATH)/bin:$PATH"

Next install the CLI

go install github.com/googleapis/librarian/cmd/librarian@latest

Running Librarian

To see the current set of commands available, run:

librarian -help

Use the -help or -h flag for any individual command to see detailed documentation for its purpose and associated flags. For example:

librarian generate -h

Alternatively, if you prefer not to have librarian installed you can use the Go command to run the latest released version:

go run github.com/googleapis/librarian/cmd/librarian@latest -help
Setup and Configuration

To run librarian, you will need to configure a Github Token and set it to the LIBRARIAN_GITHUB_TOKEN environment variable. This will use the Github token as authentication to push to Github and to run Github API commands (e.g. Creating a PR and Adding Labels to a PR).

Unless specifically configured, Librarian will use HTTPS for pushing to remote. See the SSH section for push to remote via SSH.

Github Token

There are two main options to get a Github token:

  1. Use the gh cli tool to easily authenticate with github. Run the following commands once the tool is installed:
# Follow the instructions from the tool. If using SSH, see the section
# below regarding additional setup.You still need a Github Token to run
# Github API commands (e.g. creating a pull request).
gh auth login 
# This will output the token to use as the Github Token
gh auth token

This will create a token with the repo scope.

  1. Alternatively, follow the steps listed in the Github guide to create a Personal Access Token (PAT). You will need the repo scope for your token.

Once you have created a token, set the token as the environment variable:

export LIBRARIAN_GITHUB_TOKEN={YOUR_TOKEN_HERE}
Using SSH

There are two main ways to configure SSH:

  1. Using the gh cli to upload your SSH public key to Github. When following the steps in the gh cli tool, you will select your public key to be added to Github. Additionally, you will need to add your private key to the ssh-agent.

Typically, your private keys will be ~/.ssh/id_ed25519 or ~/.ssh/id_rsa and your public keys will be the same with the .pub suffix. You should be able to see this by running ls ~/.ssh. If you do not see a public/ private key combination, you can follow this guide to generate a new key.

Running the following commands to add your private key to ssh-agent:

# This will start the ssh-agent if it hasn't already been started
eval "$(ssh-agent -s)"

# This adds your private key to the ssh-agent.
# Note: The private key will not have the `.pub` suffix.
ssh-add ~/.ssh/{PRIVATE_KEY_FILE}

# Run this command to verify that your private key is added
# You should see an output of a SHA with an absolute path to the private key
# e.g. `256 SHA:{MY_SHA} .../.ssh/id_ed25519`
ssh-add -l
  1. Follow the steps here. You will need to either create a new SSH key or using an existing one, add it to the ssh-agent, and then upload it to Github.

Once everything has been configured, set the origin remote to the SSH URI:

git remote set-url origin git@github.com:googleapis/librarian.git

Documentation

License

Apache 2.0 - See LICENSE for more information.

Directories

Path Synopsis
cmd
automation command
Automation provides logic to trigger Cloud Build jobs that run Librarian commands for any repository listed in internal/automation/prod/repositories.yaml.
Automation provides logic to trigger Cloud Build jobs that run Librarian commands for any repository listed in internal/automation/prod/repositories.yaml.
librarian command
Librarian manages Google API client libraries by automating onboarding, regeneration, and release.
Librarian manages Google API client libraries by automating onboarding, regeneration, and release.
sideflip command
Command sideflip creates, generates, and release client libraries.
Command sideflip creates, generates, and release client libraries.
sidekick command
surfer command
Command surfer generates gcloud command YAML files.
Command surfer generates gcloud command YAML files.
containers module
internal
automation
Package automation implements the command-line interface and core logic for Librarian's automated workflows.
Package automation implements the command-line interface and core logic for Librarian's automated workflows.
cli
Package cli defines a lightweight framework for building CLI commands.
Package cli defines a lightweight framework for building CLI commands.
command
Package command provides helpers to execute external commands with logging.
Package command provides helpers to execute external commands with logging.
config
Package config defines configuration used by the CLI.
Package config defines configuration used by the CLI.
container/java command
container/java/bazel
Package bazel provides utilities for parsing BUILD.bazel files.
Package bazel provides utilities for parsing BUILD.bazel files.
container/java/execv
Package execv provides a helper function for executing external commands.
Package execv provides a helper function for executing external commands.
container/java/languagecontainer
Package languagecontainer defines LanguageContainer interface and the Run function to execute commands within the container.
Package languagecontainer defines LanguageContainer interface and the Run function to execute commands within the container.
container/java/languagecontainer/generate
Package generate contains types for language container's generate command.
Package generate contains types for language container's generate command.
container/java/languagecontainer/release
Package release contains types for language container's release command.
Package release contains types for language container's release command.
container/java/message
Package message defines data types which the Librarian CLI and language containers exchange.
Package message defines data types which the Librarian CLI and language containers exchange.
container/java/pom
Package pom handles the generation of Maven pom.xml files for a Java library.
Package pom handles the generation of Maven pom.xml files for a Java library.
container/java/protoc
Package protoc provides utilities for constructing protoc command arguments.
Package protoc provides utilities for constructing protoc command arguments.
container/java/release
Package release contains the implementation of the release-stage command.
Package release contains the implementation of the release-stage command.
docker
Package docker provides the interface for running language-specific Docker containers which conform to the Librarian container contract.
Package docker provides the interface for running language-specific Docker containers which conform to the Librarian container contract.
fetch
Package fetch provides utilities for fetching GitHub repository metadata and computing checksums.
Package fetch provides utilities for fetching GitHub repository metadata and computing checksums.
github
Package github provides operations on GitHub repos, abstracting away go-github (at least somewhat) to only the operations Librarian needs.
Package github provides operations on GitHub repos, abstracting away go-github (at least somewhat) to only the operations Librarian needs.
gitrepo
Package gitrepo provides operations on git repos.
Package gitrepo provides operations on git repos.
images
Package images provides operations around docker images.
Package images provides operations around docker images.
integration
Package integration contains integration and e2e tests for the Librarian project.
Package integration contains integration and e2e tests for the Librarian project.
librarian
Package librarian provides the core implementation for the Librarian CLI tool.
Package librarian provides the core implementation for the Librarian CLI tool.
semver
Package semver provides functionality for parsing, comparing, and manipulating semantic version strings according to the SemVer 2.0.0 spec.
Package semver provides functionality for parsing, comparing, and manipulating semantic version strings according to the SemVer 2.0.0 spec.
sideflip/sideflip
Package sideflip provides functionality for onboarding, generating and releasing Google Cloud client libraries.
Package sideflip provides functionality for onboarding, generating and releasing Google Cloud client libraries.
sidekick/api
Package api defines the data model representing a parsed API surface.
Package api defines the data model representing a parsed API surface.
sidekick/api/apitest
Package apitest provides helper functions for testing the api package.
Package apitest provides helper functions for testing the api package.
sidekick/codec_sample
Package codec_sample provides an example implementation of a code generator.
Package codec_sample provides an example implementation of a code generator.
sidekick/config
Package config provides functionality for working with the sidekick.toml configuration file.
Package config provides functionality for working with the sidekick.toml configuration file.
sidekick/dart
Package dart implements a native Dart code generator.
Package dart implements a native Dart code generator.
sidekick/language
Package language provides common utilities for language-specific code generation
Package language provides common utilities for language-specific code generation
sidekick/license
Package license provides functions for generating license header text.
Package license provides functions for generating license header text.
sidekick/parser
Package parser reads specifications and converts them into the `genclient.API` model.
Package parser reads specifications and converts them into the `genclient.API` model.
sidekick/parser/discovery
Package discovery parses Google Discovery Documents into the sidekick abstract API model (`api.API`).
Package discovery parses Google Discovery Documents into the sidekick abstract API model (`api.API`).
sidekick/parser/httprule
Package httprule provides a parser for the path templates found in [google.api.http] annotations.
Package httprule provides a parser for the path templates found in [google.api.http] annotations.
sidekick/parser/svcconfig
Package svcconfig contains helper functions to parse service config files.
Package svcconfig contains helper functions to parse service config files.
sidekick/protobuf
Package protobuf provides utilities for handling protobuf files.
Package protobuf provides utilities for handling protobuf files.
sidekick/rust
Package rust implements a native Rust code generator.
Package rust implements a native Rust code generator.
sidekick/rust_prost
Package rust_prost implements a Rust code generator using the prost toolchain.
Package rust_prost implements a Rust code generator using the prost toolchain.
sidekick/rust_release
Package rustrelease implements the release automation logic for Rust crates.
Package rustrelease implements the release automation logic for Rust crates.
sidekick/sample
Package sample provides sample data for testing.
Package sample provides sample data for testing.
sidekick/sidekick
Package sidekick provides functionality for automating code generation.
Package sidekick provides functionality for automating code generation.
surfer/gcloud
Package gcloud generates gcloud command YAML files.
Package gcloud generates gcloud command YAML files.
surfer/surfer
Package surfer provides the core implementation for the surfer CLI tool.
Package surfer provides the core implementation for the surfer CLI tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL