Skip to content

Commit

Permalink
Merge pull request rails#47694 from JuanVqz/backport-fix-npm-release-…
Browse files Browse the repository at this point in the history
…tags

Backport npm release tags
  • Loading branch information
rafaelfranca committed Mar 16, 2023
2 parents f851f5a + b086a96 commit 8635ee2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tasks/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,24 @@

if File.exist?("#{framework}/package.json")
Dir.chdir("#{framework}") do
npm_tag = /[a-z]/.match?(version) ? "pre" : "latest"
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}"
npm_tag = ""
if /[a-z]/.match?(version)
npm_tag = " --tag pre"
else
remote_package_version = `npm view @rails/#{framework}@latest version`.chomp
local_major_version = version.split(".", 4)[0]
remote_major_version = remote_package_version.split(".", 4)[0]
npm_tag = remote_major_version <= local_major_version ? " --tag latest" : " --tag v#{local_major_version}"
end

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

0 comments on commit 8635ee2

Please sign in to comment.