|
| 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 | +import ( |
| 18 | + "context" |
| 19 | + "fmt" |
| 20 | + |
| 21 | + "github.com/googleapis/librarian/internal/cli" |
| 22 | + "github.com/googleapis/librarian/internal/config" |
| 23 | +) |
| 24 | + |
| 25 | +// cmdTagAndRelease is the command for the `release tag-and-release` subcommand. |
| 26 | +var cmdTagAndRelease = &cli.Command{ |
| 27 | + Short: "release tag-and-release tags and creates a GitHub release for a merged pull request.", |
| 28 | + UsageLine: "librarian release tag-and-release [arguments]", |
| 29 | + Long: "Tags and creates a GitHub release for a merged pull request.", |
| 30 | + Run: func(ctx context.Context, cfg *config.Config) error { |
| 31 | + runner, err := newTagAndReleaseRunner(cfg) |
| 32 | + if err != nil { |
| 33 | + return err |
| 34 | + } |
| 35 | + return runner.run(ctx) |
| 36 | + }, |
| 37 | +} |
| 38 | + |
| 39 | +func init() { |
| 40 | + cmdTagAndRelease.Init() |
| 41 | + fs := cmdTagAndRelease.Flags |
| 42 | + cfg := cmdGenerate.Config |
| 43 | + |
| 44 | + addFlagRepo(fs, cfg) |
| 45 | + addFlagPR(fs, cfg) |
| 46 | +} |
| 47 | + |
| 48 | +type tagAndReleaseRunner struct { |
| 49 | + cfg *config.Config |
| 50 | +} |
| 51 | + |
| 52 | +func newTagAndReleaseRunner(cfg *config.Config) (*tagAndReleaseRunner, error) { |
| 53 | + if cfg.GitHubToken == "" { |
| 54 | + return nil, fmt.Errorf("`LIBRARIAN_GITHUB_TOKEN` must be set") |
| 55 | + } |
| 56 | + return &tagAndReleaseRunner{ |
| 57 | + cfg: cfg, |
| 58 | + }, nil |
| 59 | +} |
| 60 | + |
| 61 | +func (r *tagAndReleaseRunner) run(ctx context.Context) error { |
| 62 | + return nil |
| 63 | +} |
0 commit comments