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

@ -110,7 +110,6 @@
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 @@
# 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