Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to create releases. #129

Merged
merged 22 commits into from Dec 25, 2013
Merged

Conversation

calavera
Copy link
Contributor

This PR adds a new command to create releases with gh.

It combines two steps in a single command.

Running gh release v1.0.0 this command will perform two tasks:

  1. Create a release in your github repo for the tag v1.0.0.
  2. Upload any asset that it finds under the directory releases/v1.0.0.

The location of the assets can be modified using the flag -a.
The flags -p and -d can be passed to create a prerelease or a draft.

This command will open EDITOR if there is no message or file to get the title and the body from.

@owenthereal
Copy link
Owner

contentType := http.DetectContentType(content)

fmt.Printf("-- Uploading %s to %s\n", contentType, uploadUrl.String())
request, err := http.NewRequest("POST", uploadUrl.String(), asset)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@technoweenie I'm having issues uploading the asset as the body of the request, it's probably something that I'm doing wrong.

  • I pass the file as a body for the request, since it's an *io.Reader.
  • The url where I send the request is something like this: https://uploads.github.com/repos/calavera/testGoPack/releases/128568/assets?name=1.txt
  • The content type is detected as text/plain which is correct.

The api gives me a status code 422, which is "Unprocessable entity".

Any recommendation?

@calavera
Copy link
Contributor Author

@jingweno this is working pretty nicely now. It's a lot of code to review, so no rush.

There are a bunch of testing releases in this repo: https://github.com/calavera/testGoPack/releases

The most recents are https://github.com/calavera/testGoPack/releases/tag/v1.0.21 and https://github.com/calavera/testGoPack/releases/tag/v1.0.20

@owenthereal
Copy link
Owner

Wow, this looks awesome! 💯 Give me a day or two to play with it

@calavera calavera mentioned this pull request Dec 23, 2013
@@ -320,9 +320,11 @@ For more details, run `gh help alias`.

### gh release (beta)

$ gh release
$ gh releases
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of merging the list and the create? Say gh release to list and gh release add to create, by following the git convention

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. add doesn't really sound right, maybe gh release create? or is it too long? maybe I'm just over thinking.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create actually sounds more accurate. Good call

@owenthereal
Copy link
Owner

This is interesting. I just created a draft release with gh, the title appears as untagged-62d7a5bd55cc2a3979c6. The title should be "Gee". When you click into the release, it actually displays ok.

Is that normal? It may be a API bug or some behaviours I wasn't aware. The repo is here.

screen shot 2013-12-23 at 2 53 38 pm

screen shot 2013-12-23 at 2 56 24 pm

@calavera
Copy link
Contributor Author

Thanks for the review @jingweno, I'm going to address the issues today.

I think the "untagged-..." name is right for drafts, the behavior is the same when you create a draft via the UI.

@owenthereal
Copy link
Owner

@calavera Cool. Thanks for the clarification. Ya, I just realized it's the same thing I got from the UI.

@owenthereal
Copy link
Owner

@calavera Thanks for the contributions! The PR in general looks great except for some minor issues. Let me know if you need any help

* master:
  Gramma issue in README
  Bump homebrew-gh which fixes sha and download path
  Bump homebrew-gh submodule to 1.0.0
  Bump version to v1.0.0
  Make it explicit that multiple credentials are allowed
  Quote path
  Add link to available setting
  Add autoupdate setting to README
  Make sure we load the deprecated configuration and override it with the new one.
  Save the new config after assigning the credentials.
  Save the configuration with the new format when the deprecated one is detected.
  Update versions automatically when autoupdate is set to true.
@calavera
Copy link
Contributor Author

@jingweno I did some progress with this PR, the only things missing to change are the argument validation and the command definition, I'm going to use gh release create like we agreed.

I added a super simple progress indicator, what do you think?

gh-release-progress

@owenthereal
Copy link
Owner

@calavera I just pulled down your changes and played with it. It looks so much better now! 🤘

@calavera
Copy link
Contributor Author

@jingweno I'm not really sure if we should address the subcommands in this PR. After reading the arguments implementation I feel like I'd need to change quite a few things.

What do you think about handling that in another PR? We could also solve other issues there too. For instance, the flags are positional, if you set flags after the arguments they are completely ignored. I think we could handle all the issues with args/flags parsing in a different issue/PR better.

@owenthereal
Copy link
Owner

@calavera For sure, let's merge this in

@calavera
Copy link
Contributor Author

🆒 I'm merging this!

calavera pushed a commit that referenced this pull request Dec 25, 2013
Add command to create releases.
@calavera calavera merged commit 9be0bb8 into owenthereal:master Dec 25, 2013
@calavera calavera deleted the gh_release branch December 25, 2013 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants