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

Allow setting --otp via GEM_HOST_OTP_CODE #4697

Merged
merged 1 commit into from Jun 29, 2021
Merged

Allow setting --otp via GEM_HOST_OTP_CODE #4697

merged 1 commit into from Jun 29, 2021

Conversation

CGA1123
Copy link
Contributor

@CGA1123 CGA1123 commented Jun 25, 2021

What was the end-user or developer problem that led to this PR?

For release automation it can be nice to want to pass in the OTP via
some UI (e.g. a workflow_dispatch input on GitHub Actions) and then just
be able to run rake release to publish to rubygems.

What is your fix for the problem, implemented in this PR?

This introduces a new environment variable GEM_HOST_OTP_CODE which
will take precendence over --otp command line options, allowing for
automated releases with OTP.

Make sure the following tasks are checked

@welcome
Copy link

welcome bot commented Jun 25, 2021

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

@deivid-rodriguez
Copy link
Member

I think this can be useful, yeah! But shouldn't the CLI flag still take precedence over the environment variable?

@sonalkr132 What do you think about this?

@CGA1123
Copy link
Contributor Author

CGA1123 commented Jun 25, 2021

@deivid-rodriguez I think that is also reasonable. I went with ENV first as that matches the behaviour of api_key!

@deivid-rodriguez
Copy link
Member

Oh, I see! In my opinion that's a bug in api_key priority, so I'd rather make it right for otp this time and open a ticket about the api_key issue.

@CGA1123
Copy link
Contributor Author

CGA1123 commented Jun 26, 2021

That makes sense, explicit cli options should take precedence over environment variables 👍🏼

I'll fix the precedence here and I can also likely get a PR to fix for api_key up as well!

For release automation it can be nice to want to pass in the OTP via
some UI (e.g. a workflow_dispatch input on GitHub Actions) and then just
be able to run `rake release` to publish to rubygems.

This introduces a new environment variable `GEM_HOST_OTP_CODE` which
will be checked if the `--otp` command line option is not set, allowing
for automated releases with OTP.
Copy link
Member

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

👍

@sonalkr132
Copy link
Member

LGTM. Thanks you @CGA1123

@deivid-rodriguez deivid-rodriguez changed the title Allow setting --otp via GEM_HOST_OTP_CODE Allow setting --otp via GEM_HOST_OTP_CODE Jun 29, 2021
@deivid-rodriguez
Copy link
Member

Thanks! ❤️

@deivid-rodriguez deivid-rodriguez merged commit 51184aa into rubygems:master Jun 29, 2021
deivid-rodriguez added a commit that referenced this pull request Jul 5, 2021
Allow setting `--otp` via `GEM_HOST_OTP_CODE`

(cherry picked from commit 51184aa)
@ybiquitous
Copy link
Contributor

Hi there, thank you so much for shipping this feature! I have really wanted it. 🥰

BTW, I cannot find a description about GEM_HOST_OTP_CODE in gem push —help. 🤔
Are you going to add it to the help?

@deivid-rodriguez
Copy link
Member

PR welcome!

ybiquitous added a commit to ybiquitous/rubygems that referenced this pull request Jul 9, 2021
@ybiquitous
Copy link
Contributor

@deivid-rodriguez Thanks. I've created PR #4742.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants