Skip to content

Commit e6d911d

Browse files
authored
refactor(internal/librarian): rename release init to release stage (#2743)
The release subcommand init is renamed to stage to match naming in other parts of our infrastructure. For #1926
1 parent 13d2135 commit e6d911d

File tree

41 files changed

+304
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+304
-304
lines changed

cmd/librarian/doc.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ Usage:
143143
144144
Commands:
145145
146-
init initiates a release by creating a release pull request.
146+
stage stages a release by creating a release pull request.
147147
tag tags and creates a GitHub release for a merged pull request.
148148
149-
# release init
149+
# release stage
150150
151-
The 'release init' command is the primary entry point for initiating
151+
The 'release stage' command is the primary entry point for staging
152152
a new release. It automates the creation of a release pull request by parsing
153153
conventional commits, determining the next semantic version for each library,
154154
and generating a changelog. Librarian is environment aware and will check if the
@@ -167,7 +167,7 @@ no releasable changes since the last release, the '--version' flag should be inc
167167
to set a new version for the library. The new version must be "SemVer" greater than the
168168
current version.
169169
170-
By default, 'release init' leaves the changes in your local working directory
170+
By default, 'release stage' leaves the changes in your local working directory
171171
for inspection. Use the '--push' flag to automatically commit the changes to
172172
a new branch and create a pull request on GitHub. The '--commit' flag may be
173173
used to create a local commit without creating a pull request; this flag is
@@ -178,17 +178,17 @@ whether to use HTTPS or SSH based on the remote URI.
178178
Examples:
179179
180180
# Create a release PR for all libraries with pending changes.
181-
librarian release init --push
181+
librarian release stage --push
182182
183183
# Create a release PR for a single library.
184-
librarian release init --library=secretmanager --push
184+
librarian release stage --library=secretmanager --push
185185
186186
# Manually specify a version for a single library, overriding the calculation.
187-
librarian release init --library=secretmanager --library-version=2.0.0 --push
187+
librarian release stage --library=secretmanager --library-version=2.0.0 --push
188188
189189
Usage:
190190
191-
librarian release init [flags]
191+
librarian release stage [flags]
192192
193193
Flags:
194194
@@ -228,7 +228,7 @@ Flags:
228228
229229
The 'tag' command is the final step in the release
230230
process. It is designed to be run after a release pull request, created by
231-
'release init', has been merged.
231+
'release stage', has been merged.
232232
233233
This command's primary responsibilities are to:
234234

doc/config-schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Each object in the `libraries` list represents a single library and has the foll
3737
```yaml
3838
# .librarian/config.yaml
3939

40-
# A list of files that will be provided to the 'configure' and 'release-init'
40+
# A list of files that will be provided to the 'configure' and 'release-stage'
4141
# container invocations.
4242
global_files_allowlist:
4343
# Allow the container to read and write the root go.work file during the

doc/language-onboarding.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ need to be executable by any user ID within the container.
5959

6060
### Guidelines on Language Container Runtimes
6161

62-
You should be able to run the `generate` or `release-init` commands for an API such as Google Cloud Functions in less than a
62+
You should be able to run the `generate` or `release-stage` commands for an API such as Google Cloud Functions in less than a
6363
minute. We understand that some libraries may take longer to process, however, long runtimes can adversely affect your
6464
ability to roll out emergency changes. While the CLI typically calls the container only for libraries with changes, a
6565
generator update could trigger a run for all your libraries.
@@ -246,9 +246,9 @@ The `build` command is responsible for building and testing the newly generated
246246
}
247247
```
248248

249-
### `release-init`
249+
### `release-stage`
250250

251-
The `release-init` command is the core of the release workflow. After Librarian determines the new version and collates
251+
The `release-stage` command is the core of the release workflow. After Librarian determines the new version and collates
252252
the commits for a release, it invokes this container command to apply the necessary changes to the repository.
253253

254254
The container command's primary responsibility is to update all required files with the new version and commit
@@ -260,13 +260,13 @@ global files that reference the libraries being released.
260260

261261
| Context | Type | Description |
262262
| :----------- | :------------------ | :------------------------------------------------------------------------------ |
263-
| `/librarian` | Mount (Read/Write) | Contains `release-init-request.json`. Container writes back a `release-init-response.json`. |
263+
| `/librarian` | Mount (Read/Write) | Contains `release-stage-request.json`. Container writes back a `release-stage-response.json`. |
264264
| `/repo` | Mount (Read) | Read-only contents of the language repo including any global files declared in the `config.yaml`. |
265265
| `/output` | Mount (Write) | Any files updated during the release phase should be moved to this directory, preserving their original paths. |
266-
| `command` | Positional Argument | The value will always be `release-init`. |
266+
| `command` | Positional Argument | The value will always be `release-stage`. |
267267
| flags. | Flags | Flags indicating the locations of the mounts: `--librarian`, `--repo`, `--output` |
268268

269-
**Example `release-init-request.json`:**
269+
**Example `release-stage-request.json`:**
270270

271271
The request will have entries for all libraries configured in the state.yaml -- this information may be needed for any
272272
global file edits. The libraries that are being released will be marked by the `release_triggered` field being set to
@@ -312,7 +312,7 @@ global file edits. The libraries that are being released will be marked by the `
312312
}
313313
```
314314

315-
**Example `release-init-response.json`:**
315+
**Example `release-stage-response.json`:**
316316

317317
```json
318318
{
@@ -370,7 +370,7 @@ go run ./cmd/librarian/ generate -repo=<your repository> -push
370370

371371
```
372372
export LIBRARIAN_GITHUB_TOKEN=$(gh auth token)
373-
go run ./cmd/librarian/ release init -repo=<your repository> -push
373+
go run ./cmd/librarian/ release stage -repo=<your repository> -push
374374
```
375375

376376
**Update Image Command:**

doc/library-maintainer-guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ simplest way to initiate a release is to ask `librarian` to create the release
163163
PR for you:
164164

165165
```sh
166-
$ LIBRARIAN_GITHUB_TOKEN=$(gh auth token) librarian release init -push \
166+
$ LIBRARIAN_GITHUB_TOKEN=$(gh auth token) librarian release stage -push \
167167
-repo=https://github.com/googleapis/google-cloud-go -library=bigtable
168168
```
169169

@@ -175,7 +175,7 @@ commits (e.g. for a prerelease or a patch), you can use the `-library-version`
175175
flag:
176176

177177
```sh
178-
$ LIBRARIAN_GITHUB_TOKEN=$(gh auth token) librarian release init -push \
178+
$ LIBRARIAN_GITHUB_TOKEN=$(gh auth token) librarian release stage -push \
179179
-repo=https://github.com/googleapis/google-cloud-go -library=bigtable \
180180
-library-version=1.2.3
181181
```
@@ -193,7 +193,7 @@ then create the pull request yourself:
193193
2. Create a new branch for the release (e.g. `git checkout -b release-bigtable-1.2.3`)
194194
3. Run `librarian`, specifying `-library-version` if you want/need to, as above:
195195
```sh
196-
$ librarian release init -library=bigtable -library-version=1.2.3
196+
$ librarian release stage -library=bigtable -library-version=1.2.3
197197
```
198198
4. Note the line of the `librarian` output near the end, which tells you where
199199
it has written a `pr-body.txt` file (split by key below, but all on one line

e2e_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ func TestRunGenerate_MultipleLibraries(t *testing.T) {
425425
}
426426
}
427427

428-
func TestReleaseInit(t *testing.T) {
428+
func TestReleaseStage(t *testing.T) {
429429
t.Parallel()
430430
for _, test := range []struct {
431431
name string
@@ -440,7 +440,7 @@ func TestReleaseInit(t *testing.T) {
440440
}{
441441
{
442442
name: "release with multiple commits",
443-
testDataDir: "testdata/e2e/release/init/multiple_commits",
443+
testDataDir: "testdata/e2e/release/stage/multiple_commits",
444444
libraryID: "go-google-cloud-pubsub-v1",
445445
changePath: "google-cloud-pubsub/v1",
446446
tagID: "go-google-cloud-pubsub-v1",
@@ -449,7 +449,7 @@ func TestReleaseInit(t *testing.T) {
449449
},
450450
{
451451
name: "release with multiple commits with push",
452-
testDataDir: "testdata/e2e/release/init/multiple_commits",
452+
testDataDir: "testdata/e2e/release/stage/multiple_commits",
453453
libraryID: "go-google-cloud-pubsub-v1",
454454
changePath: "google-cloud-pubsub/v1",
455455
tagID: "go-google-cloud-pubsub-v1",
@@ -459,7 +459,7 @@ func TestReleaseInit(t *testing.T) {
459459
},
460460
{
461461
name: "release with multiple nested commits",
462-
testDataDir: "testdata/e2e/release/init/multiple_nested_commits",
462+
testDataDir: "testdata/e2e/release/stage/multiple_nested_commits",
463463
libraryID: "python-google-cloud-video-live-stream-v1",
464464
changePath: "packages/google-cloud-video-live-stream",
465465
tagID: "python-google-cloud-video-live-stream-v1",
@@ -468,7 +468,7 @@ func TestReleaseInit(t *testing.T) {
468468
},
469469
{
470470
name: "release with single commit",
471-
testDataDir: "testdata/e2e/release/init/single_commit",
471+
testDataDir: "testdata/e2e/release/stage/single_commit",
472472
libraryID: "dlp",
473473
changePath: "dlp",
474474
tagID: "dlp",
@@ -524,7 +524,7 @@ func TestReleaseInit(t *testing.T) {
524524
"-tags", "e2etest",
525525
"github.com/googleapis/librarian/cmd/librarian",
526526
"release",
527-
"init",
527+
"stage",
528528
fmt.Sprintf("--repo=%s", repo),
529529
fmt.Sprintf("--output=%s", workRoot),
530530
fmt.Sprintf("--library=%s", test.libraryID),
@@ -540,7 +540,7 @@ func TestReleaseInit(t *testing.T) {
540540
cmd.Stderr = os.Stderr
541541
cmd.Stdout = os.Stdout
542542
if err := cmd.Run(); err != nil {
543-
t.Fatalf("Failed to run release init: %v", err)
543+
t.Fatalf("Failed to run release stage: %v", err)
544544
}
545545

546546
// Verify the state.yaml file content
@@ -607,7 +607,7 @@ func TestReleaseTag(t *testing.T) {
607607
### Features
608608
- feat: new feature
609609
</details>`,
610-
repoPath: "testdata/e2e/release/init/single_commit",
610+
repoPath: "testdata/e2e/release/stage/single_commit",
611611
},
612612
} {
613613
t.Run(test.name, func(t *testing.T) {

infra/prod/stage-release-worker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
#
15-
# This runs the `librarian release init` command with a provided repository,
15+
# This runs the `librarian release stage` command with a provided repository,
1616
# secret name, and optional library ID
1717
steps:
1818
- name: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-dispatcher

infra/prod/stage-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# This Cloud Build configuration is used by a Louhi flow for the Artifact
1515
# Registry (AR) Exit Gate process (go/cloud-sdk-ar-exit-gate-onboarding).
1616
#
17-
# This runs the `librarian release init` command with a provided repository,
17+
# This runs the `librarian release stage` command with a provided repository,
1818
# secret name, and optional library ID
1919
steps:
2020
- name: gcr.io/cloud-builders/git

internal/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ const (
4848
// LibrarianDir is the default directory to store librarian state/config files,
4949
// along with any additional configuration.
5050
LibrarianDir = ".librarian"
51-
// ReleaseInitRequest is a JSON file that describes which library to release.
52-
ReleaseInitRequest = "release-init-request.json"
53-
// ReleaseInitResponse is a JSON file that describes which library to change
51+
// ReleaseStageRequest is a JSON file that describes which library to release.
52+
ReleaseStageRequest = "release-stage-request.json"
53+
// ReleaseStageResponse is a JSON file that describes which library to change
5454
// after release.
55-
ReleaseInitResponse = "release-init-response.json"
55+
ReleaseStageResponse = "release-stage-response.json"
5656
// LibrarianStateFile is the name of the pipeline state file.
5757
LibrarianStateFile = "state.yaml"
5858
// LibrarianConfigFile is the name of the language-repository config file.

internal/container/java/languagecontainer/languagecontainer.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import (
3636

3737
// LanguageContainer defines the functions for language-specific container operations.
3838
type LanguageContainer struct {
39-
Generate func(context.Context, *generate.Config) error
40-
ReleaseInit func(context.Context, *release.Config) (*message.ReleaseInitResponse, error)
39+
Generate func(context.Context, *generate.Config) error
40+
ReleaseStage func(context.Context, *release.Config) (*message.ReleaseStageResponse, error)
4141
// Other container functions like Generate and Build will also be part of the struct.
4242
}
4343

@@ -65,12 +65,12 @@ func Run(args []string, container *LanguageContainer) int {
6565
case "configure":
6666
slog.Warn("languagecontainer: configure command is missing")
6767
return 1
68-
case "release-init":
69-
if container.ReleaseInit == nil {
68+
case "release-stage":
69+
if container.ReleaseStage == nil {
7070
slog.Error("languagecontainer: generate command is missing")
7171
return 1
7272
}
73-
return handleReleaseInit(flags, container)
73+
return handleReleaseStage(flags, container)
7474
case "build":
7575
slog.Warn("languagecontainer: build command is not yet implemented")
7676
return 1
@@ -104,23 +104,23 @@ func handleGenerate(flags []string, container *LanguageContainer) int {
104104
return 0
105105
}
106106

107-
func handleReleaseInit(flags []string, container *LanguageContainer) int {
107+
func handleReleaseStage(flags []string, container *LanguageContainer) int {
108108
cfg := &release.Context{}
109-
releaseInitFlags := flag.NewFlagSet("release-init", flag.ContinueOnError)
110-
releaseInitFlags.StringVar(&cfg.LibrarianDir, "librarian", "/librarian", "Path to the librarian-tool input directory. Contains release-init-request.json.")
109+
releaseInitFlags := flag.NewFlagSet("release-stage", flag.ContinueOnError)
110+
releaseInitFlags.StringVar(&cfg.LibrarianDir, "librarian", "/librarian", "Path to the librarian-tool input directory. Contains release-stage-request.json.")
111111
releaseInitFlags.StringVar(&cfg.RepoDir, "repo", "/repo", "Path to the language repo.")
112112
releaseInitFlags.StringVar(&cfg.OutputDir, "output", "/output", "Path to the output directory.")
113113
if err := releaseInitFlags.Parse(flags); err != nil {
114114
slog.Error("failed to parse flags", "error", err)
115115
return 1
116116
}
117-
requestPath := filepath.Join(cfg.LibrarianDir, "release-init-request.json")
117+
requestPath := filepath.Join(cfg.LibrarianDir, "release-stage-request.json")
118118
bytes, err := os.ReadFile(requestPath)
119119
if err != nil {
120120
slog.Error("failed to read request file", "path", requestPath, "error", err)
121121
return 1
122122
}
123-
request := &message.ReleaseInitRequest{}
123+
request := &message.ReleaseStageRequest{}
124124
if err := json.Unmarshal(bytes, request); err != nil {
125125
slog.Error("failed to parse request JSON", "error", err)
126126
return 1
@@ -129,21 +129,21 @@ func handleReleaseInit(flags []string, container *LanguageContainer) int {
129129
Context: cfg,
130130
Request: request,
131131
}
132-
response, err := container.ReleaseInit(context.Background(), config)
132+
response, err := container.ReleaseStage(context.Background(), config)
133133
if err != nil {
134-
slog.Error("release-init failed", "error", err)
134+
slog.Error("release-stage failed", "error", err)
135135
return 1
136136
}
137137
bytes, err = json.MarshalIndent(response, "", " ")
138138
if err != nil {
139139
slog.Error("failed to marshal response JSON", "error", err)
140140
return 1
141141
}
142-
responsePath := filepath.Join(cfg.LibrarianDir, "release-init-response.json")
142+
responsePath := filepath.Join(cfg.LibrarianDir, "release-stage-response.json")
143143
if err := os.WriteFile(responsePath, bytes, 0644); err != nil {
144144
slog.Error("failed to write response file", "path", responsePath, "error", err)
145145
return 1
146146
}
147-
slog.Info("languagecontainer: release-init command executed successfully")
147+
slog.Info("languagecontainer: release-stage command executed successfully")
148148
return 0
149149
}

0 commit comments

Comments
 (0)