Skip to content

gh release create question and general feedback #2133

Closed

Description

@gilcrest

CLI Feedback

What have you loved?

I really love the whole cli. Thanks a lot for making it open source as well. As a Gopher, it's really great to see this code as it's awesome! So, thanks!

What was confusing or gave you pause?

Previously, to make a release, I would commit my code locally and push to Github, add a tag to my commit (say v0.2.0) and then run git push origin v0.2.0 to create my release on Github.

With the gh cli, I don't even need to add a local tag, I just type gh release create v0.2.0 and it works, but my local git repository is not given the tag, so they are a bit disjointed. I can go and add the tag after the fact, but I'm wondering if there's a way for it to release given the local tag? Git is not my specialty, so I'm not sure if this even makes sense, but wondering how to couple my local git tag to a Github release a bit more tightly.

Thanks again for the tool - it's fantastic!

Activity

  1. added
    enhancement
    bug
    and removed
    enhancement
    on Oct 9, 2020
  2. mislav commented on Oct 12, 2020

    @mislav
    Contributor

    Thanks for the feedback! ❤️

    Previously, to make a release, I would commit my code locally and push to Github, add a tag to my commit (say v0.2.0) and then run git push origin v0.2.0 to create my release on Github.

    This does push a git tag to your GitHub repo, which shows up among "releases" for your repository, but it's not a full GitHub Release in a sense that you can edit the release notes in Markdown format or upload your own assets to it. The gh release create command helps with creating a proper Release.

    With the gh cli, I don't even need to add a local tag, I just type gh release create v0.2.0 and it works, but my local git repository is not given the tag, so they are a bit disjointed.

    I see! In case that you haven't created the v0.2.0 git tag yourself, the fact that you've created a v0.2.0 Release on GitHub will automatically create the underlying v0.2.0 git tag in your remote repository. The new tag will be created off the latest state of your default branch (e.g. main), but you can change that by passing the --target parameter to release create with a specific commit SHA or a branch name where you want the new tag to point to.

    Finally, to fetch the new git tag locally, you can do git fetch origin --tags.

    We can definitely make sure to document all this better in release create, but other than just clearer documentation, is there something else that is confusing here or that you imagine should work differently?

    For example, would you expect us to automatically pull the newly created git tag locally after you've done release create?

  3. gilcrest commented on Oct 17, 2020

    @gilcrest
    Author

    Super helpful information, thanks so much!

    Would it be possible to add the tag locally and then use the tag for a target? e.g. gh release create --target-tag v0.2.0 or just recognize a semver pattern to enable gh release create --target v0.2.0

    Or does that not make sense? Pulling the tag locally after could work, but my typical flow, because of Go Modules, is to tag in my IDE and then push releases. I'm probably an outlier, I'm no Git wiz and can change my process!

    Thanks again.

  4. added
    more-info-needed
    on Oct 19, 2020
  5. mislav commented on Oct 19, 2020

    @mislav
    Contributor

    @gilcrest It's absolutely possible to first create a tag locally and then create a release for it. The --target argument accepts commit SHAs, branch names, or tag names.

    git tag v0.2.0
    git push origin v0.2.0
    gh release create v0.2.0 --target v0.2.0
    

    Actually, I think that --target v0.2.0 in the last command isn't needed, because the v0.2.0 Release will automatically get tied to the v0.2.0 git tag if one already exists. The --target argument only has effect, I think, when the git tag doesn't yet exist in the repository.

    Does this answer your questions? Is there something that you imagine gh should do differently around release create? I'm hoping to define something actionable, if a change is needed, from this thread. 🙇

  6. gilcrest commented on Oct 19, 2020

    @gilcrest
    Author

    @mislav - again super helpful, thank you!

    What was confusing for me was that your documentation at https://cli.github.com/manual/gh_release_create for --target is as follows:

    --target branch     Target branch or commit SHA (default: main branch)
    

    I think for most people, they would implicitly understand that a tag is just a pointer to a commit SHA. I am clearly not most people :)

    Your note, "The --target argument accepts commit SHAs, branch names, or tag names." made me go back and look at git documentation to dig in again to what a tag actually is so I could connect the dots that the tag is essentially the commit SHA.

    I think it would be helpful to include tag in the documentation, e.g.

    --target branch Target branch, tag or commit SHA (default: main branch)

    or something to that effect.

    In addition, on the same page, I think it would be helpful to add a link to documentation about what a Github Release is vs. just a tag. I started using the gh tool without actually truly understanding what a Github release is vs. just a tagged release.

    Finally, considering your note ("Actually, I think that --target v0.2.0 in the last command isn't needed, because the v0.2.0 Release will automatically get tied to the v0.2.0 git tag if one already exists. The --target argument only has effect, I think, when the git tag doesn't yet exist in the repository.") -- understanding whether or not the --target tag isn't needed for certain will be helpful. I can and should test this for myself though!

    I'm sorry to take up your time.

    Thanks again for all your help!

    Dan

  7. ffigiel commented on Nov 27, 2020

    @ffigiel

    I ran into some issues when creating a release for a specific commit. Apologies if this belongs to a dedicated ticket.

    1. I tried
    gh release create v0.14.9 --target e6e5f334
    

    and got

    HTTP 422: Validation Failed (https://api.github.com/repos/RstorLabs/rocket-gui/releases)
    Release.target_commitish is invalid
    
    1. I found your issue on github, then tried creating a local tag and specifying it as --target as @mislav suggested, same problem
    2. I tried pushing the tag and then creating a release, same problem
    3. I tried specifying the full commit hash. Finally, this worked
    gh release create v0.14.9 --target e6e5f3346491c98e9d2e8caf7e4114a6ef7dbea1
    

    Why did a short commit hash not work? It was not ambiguous, I am sure of it. Does the target need to be a specific length to be interpreted as a commit hash?

    It would have been very helpful if gh release create --help or the error message mentioned this

  8. added and removed
    bug
    more-info-needed
    on Dec 1, 2020
  9. mislav commented on Dec 1, 2020

    @mislav
    Contributor

    @gilcrest This was all great feedback for us. Thank you! <3 We will try to improve the docs.

    @megapctr I think that the short commit hash would not work as a commit SHA because it could be mis-interpreted as a branch name. E.g. deadbeef is a valid short commit hash, but is also valid words in English language and could possibly be a branch name. To avoid ambiguity, I think full commit SHAs are required. This would be also a good note to add to our docs.

  10. ffigiel commented on Dec 1, 2020

    @ffigiel

    @mislav thank you for clarification. Would it make sense for gh release create to target HEAD by default, like git tag does?

  11. mislav commented on Dec 2, 2020

    @mislav
    Contributor

    @megapctr gh release create (with no --target) will target the latest state of the main branch as it is in the GitHub repository. Were you expecting that it targets HEAD as in, the currently checked out commit in your local repo?

  12. ffigiel commented on Dec 2, 2020

    @ffigiel

    @mislav yes, I expected it to target the current commit.

    For context, I usually make two commits for a release: First updates the changelog to rename "dev" section to the version number. Second adds a new dev section to the changelog. Then I make a release targeting the first commit.

    Knowing I need to specify --target with a full commit SHA lets me do what I need. I thought it may be helpful to the CLI team to point out how a similar tool (git tag) behaves differently in this regard.

  13. mislav commented on Dec 3, 2020

    @mislav
    Contributor

    @megapctr Thank you for explaining. Since gh release create can be run outside of a context of a local git repo (e.g. gh release create -R cli/cli), I do not think that we should take local HEAD as a default target, since sometimes there will be no local HEAD. However, your input will help us improve documentation on the matter!

  14. added
    core
    on Jan 28, 2021
  15. victorlin commented on Jun 23, 2022

    @victorlin

    @mislav: The --target argument accepts commit SHAs, branch names, or tag names.

    Are tag names really supported? I just tried something like gh release create v0.2.0 --target v0.2.0 and got HTTP 422: Release.target_commitish is invalid. The docs also don't say anything about supporting tag names:

    --target <branch> Target branch or full commit SHA (default: main branch)

  16. mislav commented on Jun 27, 2022

    @mislav
    Contributor

    @victorlin They should be. gh release create v0.2.0 --target v0.2.0 should have worked for you if a v0.2.0 tag exists in your remote repository. Was that the case? If so, you could try to use a fully qualified git ref: gh release create v0.2.0 --target refs/tags/v0.2.0. Update: no, that doesn't work.

    Otherwise, I have a hunch that if you do gh release create v0.2.0 and not supply --target, the Release will be created for the existing git tag v0.2.0 anyway. So, you don't really need --target. Let us know if that worked!

  17. victorlin commented on Jun 27, 2022

    @victorlin

    @mislav thank you for your response! I would like to create a release only if the tag exists already, so I want to use --target to accomplish that. I just tried both --target <tag> and --target refs/tags/<tag> – neither worked. Created a separate issue for this: #5855

  18. mislav commented on Jul 11, 2022

    @mislav
    Contributor

    @victorlin Sorry for my previous misleading comment. I was just guessing that --target <tagname> could work, but since then I've learned that tag names are not valid input for this field. Right now, there doesn't seem a way to opt out of automated tag creation on release create. The best way to avoid a tag being auto-created is to ensure that a local tag is first pushed to a remote.

  19. SpaldingGreene commented on Jul 11, 2022

    @SpaldingGreene
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coredocs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions