|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package librarian |
| 16 | + |
| 17 | +const ( |
| 18 | + librarianLongHelp = "Librarian manages client libraries for Google APIs." |
| 19 | + |
| 20 | + versionLongHelp = "Version prints version information for the librarian binary." |
| 21 | + |
| 22 | + releaseLongHelp = "Manages releases of libraries." |
| 23 | + |
| 24 | + generateLongHelp = `The generate command is the primary tool for all code generation |
| 25 | +tasks. It handles both the initial setup of a new library (onboarding) and the |
| 26 | +regeneration of existing ones. Librarian works by delegating language-specific |
| 27 | +tasks to a container, which is configured in the .librarian/state.yaml file. |
| 28 | +Librarian is environment aware and will check if the current directory is the |
| 29 | +root of a librarian repository. If you are not executing in such a directory the |
| 30 | +'--repo' flag must be provided. |
| 31 | +
|
| 32 | +# Onboarding a new library |
| 33 | +
|
| 34 | +To configure and generate a new library for the first time, you must specify the |
| 35 | +API to be generated and the library it will belong to. Librarian will invoke the |
| 36 | +'configure' command in the language container to set up the repository, add the |
| 37 | +new library's configuration to the '.librarian/state.yaml' file, and then |
| 38 | +proceed with generation. |
| 39 | +
|
| 40 | +Example: |
| 41 | + librarian generate --library=secretmanager --api=google/cloud/secretmanager/v1 |
| 42 | +
|
| 43 | +# Regenerating existing libraries |
| 44 | +
|
| 45 | +You can regenerate a single, existing library by specifying either the library |
| 46 | +ID or the API path. If no specific library or API is provided, Librarian will |
| 47 | +regenerate all libraries listed in '.librarian/state.yaml'. If '--library' or |
| 48 | +'--api' is specified the whole library will be regenerated. |
| 49 | +
|
| 50 | +Examples: |
| 51 | + # Regenerate a single library by its ID |
| 52 | + librarian generate --library=secretmanager |
| 53 | +
|
| 54 | + # Regenerate a single library by its API path |
| 55 | + librarian generate --api=google/cloud/secretmanager/v1 |
| 56 | +
|
| 57 | + # Regenerate all libraries in the repository |
| 58 | + librarian generate |
| 59 | +
|
| 60 | +# Workflow and Options: |
| 61 | +
|
| 62 | +The generation process involves delegating to the language container's |
| 63 | +'generate' command. After the code is generated, the tool cleans the destination |
| 64 | +directories and copies the new files into place, according to the configuration |
| 65 | +in '.librarian/state.yaml'. |
| 66 | +
|
| 67 | +- If the '--build' flag is specified, the 'build' command is also executed in |
| 68 | + the container to compile and validate the generated code. |
| 69 | +- If the '--push' flag is provided, the changes are committed to a new branch, |
| 70 | + and a pull request is created on GitHub. Otherwise, the changes are left in |
| 71 | + your local working directory for inspection. |
| 72 | +
|
| 73 | +Example with build and push: |
| 74 | + SDK_LIBRARIAN_GITHUB_TOKEN=xxx librarian generate --push --build` |
| 75 | + |
| 76 | + releaseInitLongHelp = `The 'release init' command is the primary entry point for initiating |
| 77 | +a new release. It automates the creation of a release pull request by parsing |
| 78 | +conventional commits, determining the next semantic version for each library, |
| 79 | +and generating a changelog. Librarian is environment aware and will check if the |
| 80 | +current directory is the root of a librarian repository. If you are not |
| 81 | +executing in such a directory the '--repo' flag must be provided. |
| 82 | +
|
| 83 | +This command scans the git history since the last release, identifies changes |
| 84 | +(feat, fix, BREAKING CHANGE), and calculates the appropriate version bump |
| 85 | +according to semver rules. It then delegates all language-specific file |
| 86 | +modifications, such as updating a CHANGELOG.md or bumping the version in a pom.xml, |
| 87 | +to the configured language-specific container. |
| 88 | +
|
| 89 | +By default, 'release init' leaves the changes in your local working directory |
| 90 | +for inspection. Use the '--push' flag to automatically commit the changes to |
| 91 | +a new branch and create a pull request on GitHub. The '--commit' flag may be |
| 92 | +used to create a local commit without creating a pull request; this flag is |
| 93 | +ignored if '--push' is also specified. |
| 94 | +
|
| 95 | +Examples: |
| 96 | + # Create a release PR for all libraries with pending changes. |
| 97 | + librarian release init --push |
| 98 | +
|
| 99 | + # Create a release PR for a single library. |
| 100 | + librarian release init --library=secretmanager --push |
| 101 | +
|
| 102 | + # Manually specify a version for a single library, overriding the calculation. |
| 103 | + librarian release init --library=secretmanager --library-version=2.0.0 --push` |
| 104 | + |
| 105 | + tagAndReleaseLongHelp = `The 'tag-and-release' command is the final step in the release |
| 106 | +process. It is designed to be run after a release pull request, created by |
| 107 | +'release init', has been merged. |
| 108 | +
|
| 109 | +This command's primary responsibilities are to: |
| 110 | +
|
| 111 | +- Create a Git tag for each library version included in the merged pull request. |
| 112 | +- Create a corresponding GitHub Release for each tag, using the release notes |
| 113 | + from the pull request body. |
| 114 | +- Update the pull request's label from 'release:pending' to 'release:done' to |
| 115 | + mark the process as complete. |
| 116 | +
|
| 117 | +You can target a specific merged pull request using the '--pr' flag. If no pull |
| 118 | +request is specified, the command will automatically search for and process all |
| 119 | +merged pull requests with the 'release:pending' label from the last 30 days. |
| 120 | +
|
| 121 | +Examples: |
| 122 | + # Tag and create a GitHub release for a specific merged PR. |
| 123 | + librarian release tag-and-release --repo=https://github.com/googleapis/google-cloud-go --pr=https://github.com/googleapis/google-cloud-go/pull/123 |
| 124 | +
|
| 125 | + # Find and process all pending merged release PRs in a repository. |
| 126 | + librarian release tag-and-release --repo=https://github.com/googleapis/google-cloud-go` |
| 127 | +) |
0 commit comments