Skip to content

Commit 72a0ad4

Browse files
authored
Merge pull request cli#2910 from cli/docs-release-create
Clarify handling of git tags during `release create`
2 parents 481ec92 + 9dcf47d commit 72a0ad4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pkg/cmd/release/create/create.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,30 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
6161
var notesFile string
6262

6363
cmd := &cobra.Command{
64+
DisableFlagsInUseLine: true,
65+
6466
Use: "create <tag> [<files>...]",
6567
Short: "Create a new release",
66-
Long: heredoc.Doc(`
68+
Long: heredoc.Docf(`
6769
Create a new GitHub Release for a repository.
6870
6971
A list of asset files may be given to upload to the new release. To define a
70-
display label for an asset, append text starting with '#' after the file name.
71-
`),
72+
display label for an asset, append text starting with %[1]s#%[1]s after the file name.
73+
74+
If a matching git tag does not yet exist, one will automatically get created
75+
from the latest state of the default branch. Use %[1]s--target%[1]s to override this.
76+
To fetch the new tag locally after the release, do %[1]sgit fetch --tags origin%[1]s.
77+
78+
To create a release from an annotated git tag, first create one locally with
79+
git, push the tag to GitHub, then run this command.
80+
`, "`"),
7281
Example: heredoc.Doc(`
7382
# use release notes from a file
7483
$ gh release create v1.2.3 -F changelog.md
7584
85+
# upload all tarballs in a directory as release assets
86+
$ gh release create v1.2.3 ./dist/*.tgz
87+
7688
# upload a release asset with a display label
7789
$ gh release create v1.2.3 '/path/to/asset.zip#My display label'
7890
`),
@@ -116,7 +128,7 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
116128

117129
cmd.Flags().BoolVarP(&opts.Draft, "draft", "d", false, "Save the release as a draft instead of publishing it")
118130
cmd.Flags().BoolVarP(&opts.Prerelease, "prerelease", "p", false, "Mark the release as a prerelease")
119-
cmd.Flags().StringVar(&opts.Target, "target", "", "Target `branch` or commit SHA (default: main branch)")
131+
cmd.Flags().StringVar(&opts.Target, "target", "", "Target `branch` or full commit SHA (default: main branch)")
120132
cmd.Flags().StringVarP(&opts.Name, "title", "t", "", "Release title")
121133
cmd.Flags().StringVarP(&opts.Body, "notes", "n", "", "Release notes")
122134
cmd.Flags().StringVarP(&notesFile, "notes-file", "F", "", "Read release notes from `file`")

0 commit comments

Comments
 (0)