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 gem release --github #73

Merged
merged 11 commits into from
Oct 15, 2019
Merged

Add gem release --github #73

merged 11 commits into from
Oct 15, 2019

Conversation

svenfuchs
Copy link
Owner

@svenfuchs svenfuchs commented Mar 24, 2018

Untested ...

refs #62

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 96.253% when pulling 1ad2c98 on sf-github-release into 195f6d1 on master.

Repository owner deleted a comment from coveralls Mar 24, 2018
@kennyadsl
Copy link
Contributor

kennyadsl commented Jan 28, 2019

Hey @svenfuchs ! Is there any plan to merge this feature? I want to use this gem for https://github.com/solidusio/solidus to make the release process easier and uniform. Part of our current releases workflow includes this step, and we'd be using --github option.

Let me know if I can help to push this forward, thanks!

@kennyadsl kennyadsl mentioned this pull request Jan 28, 2019
4 tasks
@PikachuEXE PikachuEXE force-pushed the sf-github-release branch 2 times, most recently from 707ae97 to 1b0e0dc Compare July 4, 2019 07:43
@PikachuEXE
Copy link
Collaborator

Rebase, fixed heredoc for Ruby 2.2 & all builds passed
Anyone tested this new feature?
@kennyadsl ?

@kennyadsl
Copy link
Contributor

Not yet, but I'm still interested. Is there an easy way to run the gem from this branch locally?

@PikachuEXE PikachuEXE force-pushed the sf-github-release branch 2 times, most recently from 37b1fcd to f6f8146 Compare July 5, 2019 03:06
@PikachuEXE PikachuEXE force-pushed the sf-github-release branch from f6f8146 to 55af839 Compare July 5, 2019 03:10
@PikachuEXE
Copy link
Collaborator

Fixed several bugs like

  • missing error message
  • unable to pass option in release command for github
  • missing support for pretend mode
  • Token not passed to request

I think there might be more bugs
Since I only tested with pretend mode :P

@PikachuEXE
Copy link
Collaborator

In your gem project's Gemfile:

gem "gem-release", git: "https://github.com/svenfuchs/gem-release.git", branch: "sf-github-release"

Make sure you use bundle exec gem release (otherwise global installed version might be picked up)

@kennyadsl
Copy link
Contributor

@PikachuEXE what I was trying to do is testing the gem locally without adding it to the bundle via the Gemfile. Do you think it's possible? Otherwise, I can definitely use github:+branch: or path: options. Thanks!

@PikachuEXE
Copy link
Collaborator

Even I when I test local gem-release code I need to add it via path option to Gemfile
I can't think of a way around it mate :)

Just open a new branch and commit Gemfile changes on it

@PikachuEXE
Copy link
Collaborator

@kennyadsl Got any progress on testing?

@kennyadsl
Copy link
Contributor

@PikachuEXE I’m on vacation now and didn’t have the chance to test this yet, planning to give it a try when I come back in a couple of weeks. Will update here as well, thanks!

@kennyadsl
Copy link
Contributor

@PikachuEXE I've just made the first test. I created this test repository https://github.com/kennyadsl/test_gem_release_gh (I can give you access if you want).

Tried to run the first release with pretend and github options:

bundle exec gem release --pretend -t -p  --github --t MY_TOKEN -d "Released via gem Release" -r "kennyadsl/test_gem_release_gh"

And I get this error:

Releasing test_gem_release_gh with version 0.1.0
Building test_gem_release_gh.gemspec
$ gem build test_gem_release_gh.gemspec

Pushing test_gem_release_gh-0.1.0.gem
$ gem push test_gem_release_gh-0.1.0.gem

Deleting left over gem file test_gem_release_gh-0.1.0.gem
$ rm -f test_gem_release_gh-0.1.0.gem

Tagging test_gem_release_gh as version 0.1.0
Creating git tag v0.1.0
$ git tag -am "tag v0.1.0" v0.1.0

Pushing tags to the origin git repository
$ git push --tags origin
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Release::Cmds::Release::GitHub
Did you mean?  Gem::Release::Cmds::Github

@PikachuEXE
Copy link
Collaborator

I think you are using old version of this branch
That was the first bug I found and fixed it soon after (with force push so I don't remember when did I fix it)
I guess you should make changes to Gemfile as mentioned in
#73 (comment)
Maybe run bundle update too

@kennyadsl
Copy link
Contributor

That's what I did but it still keep 29124d7ed83cce45871a1e148a821ef2aa7987c2.

If I try to add the last commit ref with , ref: "55af839" I get

Revision 55af839 does not exist in the repository https://github.com/svenfuchs/gem-release.git. Maybe you misspelled it?

🤔

@kennyadsl
Copy link
Contributor

Did it, I needed to use a longer ref!

@kennyadsl
Copy link
Contributor

@kennyadsl
Copy link
Contributor

I've split the command into two separate ones (maybe the error is still there trying to use --github option from the gem release command) and now I have a different error when creating the GH release:

> bundle exec gem release -t -p # this works!

> bundle exec gem github --pretend --t MY_TOKEN -d "Released via gem Release" -r "kennyadsl/test_gem_release_gh"

Creating GitHub release for test_gem_release_gh version v0.1.0
ERROR:  While executing gem ... (EOFError)
    end of file reached

@PikachuEXE
Copy link
Collaborator

If I understand it correctly
The new command cannot be run separately
https://github.com/svenfuchs/gem-release/tree/master/lib/rubygems/commands

You can run
bundle exec gem release --github --pretend -t MY_TOKEN -d "Released via gem Release" -r "kennyadsl/test_gem_release_gh"

@kennyadsl
Copy link
Contributor

Got it! In my previous attempt (in January) I did setup bundle local to always use my local version of gem-release. This was making the Gemfile changes uneffective and I was still using the first version as you pointed out.

It's now working, I'll release a couple of test version for my test gem and will update here with results, thanks for your help!

@kennyadsl
Copy link
Contributor

On a side note, I've noticed something unexpected: when I run:

bundle exec gem bump -p -s -t -r

it also creates new releases on GitHub. Not sure how since I didn't run the release --github command and didn't specify the GH token anywhere (maybe those options are cached somewhere?). Or maybe it is now done by GitHub itself when a new tag is created (I can't find any resources about this in the GitHub documentation)?


If I split the command:

bundle exec gem bump -p -s -t  # this works!
bundle exec gem release --github -t MY_TOKEN -d "Released via gem-release" -r "kennyadsl/test_gem_release_gh"

I get this error:

Creating GitHub release for test_gem_release_gh version v0.1.8
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Release::VERSION
Did you mean?  Gem::Release::Version
               Gem::Version
               Gem::VERSION

Another thing: I think we should change the option -t for --token since in the gem release command it's already present for --tag. If gem release --github should always be run as a stand-alone command maybe it's better to create a new gem github command?

Otherwise we'll have:

ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Release::VERSION
Did you mean?  Gem::Release::Version
               Gem::Version
               Gem::VERSION
GitHub API URLs protocol is https so we have to explicitely
set the client to use this option, otherwise we would have an
error:

ERROR:  While executing gem ... (EOFError)
    end of file reached

See also https://stackoverflow.com/a/9227933/1460504
@kennyadsl
Copy link
Contributor

I fixed a couple of issues with #84 but the release is still not created in GH and I'm trying to figure out why. Let me know if you have any idea. 🙂

There was a typo and that parameter is required to create the release.
@kennyadsl
Copy link
Contributor

This is the error:

Status: 422
{"message":"Invalid request.\n\nFor 'properties/body', nil is not a string.","documentation_url":"https://developer.github.com/v3/repos/releases/#create-a-release"}

and it was due to a typo in declaring the argument names. I fixed it in the attached PR and I am now able to create a release on GH! 🎉

Fix some issues with --github release
@PikachuEXE
Copy link
Collaborator

Let me work on it later this week (well Friday)
Maybe I can steal some time to work on this today too

@PikachuEXE
Copy link
Collaborator

Sorry, too many tasks this week
I hope I got time to work on this next week 😬

@kennyadsl
Copy link
Contributor

Take your time, no hurry on my side. Thanks again for your help!

@PikachuEXE
Copy link
Collaborator

I removed the conflicting cmd line argument (short one) like -t
And print error message when rescuing abort error

Please take a look and see what else is incorrect / missing

@PikachuEXE
Copy link
Collaborator

@kennyadsl
Yo
Just a regular reminder for testing this updated PR :3

@kennyadsl
Copy link
Contributor

@PikachuEXE I tested this branch with

bundle exec gem bump -p -s -t && bundle exec gem release --github --token MY_TOKEN -d "Released via gem-release" --repo "kennyadsl/test_gem_release_gh"

And almost everything worked well:

Here's the command output:

Bumping test_gem_release_gh from version 0.1.17 to 0.1.18
Changing version in lib/test_gem_release_gh/version.rb from 0.1.17 to 0.1.18

Staging lib/test_gem_release_gh/version.rb
$ git add lib/test_gem_release_gh/version.rb

Creating commit
$ git commit -m "Bump test_gem_release_gh to 0.1.18" -S
[master 650a5d9] Bump test_gem_release_gh to 0.1.18
 1 file changed, 1 insertion(+), 1 deletion(-)

Pushing to the origin git repository
$ git push origin
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 808 bytes | 269.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:kennyadsl/test_gem_release_gh.git
   68ab16c..650a5d9  master -> master

Tagging test_gem_release_gh as version 0.1.18
Creating git tag v0.1.18
$ git tag -am "tag v0.1.18" v0.1.18 --sign

Pushing tags to the origin git repository
$ git push --tags origin
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 537 bytes | 537.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To github.com:kennyadsl/test_gem_release_gh.git
 * [new tag]         v0.1.18 -> v0.1.18

All is good, thanks my friend.


Releasing test_gem_release_gh with version 0.1.18
Building test_gem_release_gh.gemspec
$ gem build test_gem_release_gh.gemspec
WARNING:  description and summary are identical
WARNING:  See http://guides.rubygems.org/specification-reference/ for help
  Successfully built RubyGem
  Name: test_gem_release_gh
  Version: 0.1.18
  File: test_gem_release_gh-0.1.18.gem

Pushing test_gem_release_gh-0.1.18.gem
$ gem push test_gem_release_gh-0.1.18.gem
Pushing gem to https://rubygems.org...
You have enabled multi-factor authentication. Please enter OTP code.
Code:   XXXXX
Successfully registered gem: test_gem_release_gh (0.1.18)

Deleting left over gem file test_gem_release_gh-0.1.18.gem
$ rm -f test_gem_release_gh-0.1.18.gem

Creating GitHub release for test_gem_release_gh version v0.1.18.
GitHub returned 201 (body: "{ ... }")

As you can see, I'm seeing the error message, even when a 201 status code is returned, I think the problem is here, since 201 is the official ok status code.

Thanks!

@PikachuEXE
Copy link
Collaborator

Just fixed expected status code in cd0ee56

@PikachuEXE
Copy link
Collaborator

I suppose I will release this next week unless there is something more to test/change
@kennyadsl

@kennyadsl
Copy link
Contributor

Fine by me, thanks again, @PikachuEXE!

@PikachuEXE PikachuEXE merged commit 0f5f238 into master Oct 15, 2019
@PikachuEXE PikachuEXE deleted the sf-github-release branch October 15, 2019 09:25
@PikachuEXE
Copy link
Collaborator

Releasing this tomorrow

@PikachuEXE
Copy link
Collaborator

Released as 2.1.0

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.

4 participants