1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Update the npm package release task to not add the latest package for every version.

This commit is contained in:
Niklas Haeusele 2022-06-28 23:15:50 +02:00
parent 7ebda0aded
commit 7a555e460f

View file

@ -110,7 +110,6 @@ npm_version = version.gsub(/\./).with_index { |s, i| i >= 2 ? "-" : s }
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
@ -118,7 +117,17 @@ npm_version = version.gsub(/\./).with_index { |s, i| i >= 2 ? "-" : s }
# 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