Skip to content

Commit

Permalink
Add support for YubiKey OTP codes during release
Browse files Browse the repository at this point in the history
This patch adds support for automatically getting OTP codes from your
YubiKey during release.  You must have the `ykman` commandline tool
installed, and have two accounts setup with the names `rubygems.org` and
`npmjs.com`.  For example, the output from `ykman oath accounts list` on
my machine is this:

```
$ ykman oath accounts list
npmjs.com:[email protected]
rubygems.org:[email protected]
```

If you meet these conditions, you can do `rake release` without typing
an OTP code for every gem.

If no `ykman` tool is found on your system, this will just fall back to
asking for an OTP code.
  • Loading branch information
tenderlove committed Dec 14, 2021
1 parent 0fccfb9 commit 8f83351
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tasks/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,26 @@
end

task push: :build do
sh "gem push #{gem}"
otp = ""
begin
otp = " --otp " + `ykman oath accounts code -s rubygems.org`.chomp
rescue
# User doesn't have ykman
end

sh "gem push #{gem}#{otp}"

if File.exist?("#{framework}/package.json")
Dir.chdir("#{framework}") do
npm_tag = /[a-z]/.match?(version) ? "pre" : "latest"
sh "npm publish --tag #{npm_tag}"
npm_otp = ""
begin
npm_otp = " --otp " + `ykman oath accounts code -s npmjs.com`.chomp
rescue
# User doesn't have ykman
end

sh "npm publish --tag #{npm_tag}#{npm_otp}"
end
end
end
Expand Down

0 comments on commit 8f83351

Please sign in to comment.