|
| 1 | +#release_chekcout.rb |
| 2 | +require 'rubygems' |
| 3 | +require 'open-uri' |
| 4 | +require 'net/http' |
| 5 | + |
| 6 | +def check_homebrew |
| 7 | + print "Checking homebrew forumla ... " |
| 8 | + |
| 9 | + url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/openapi-generator.rb" |
| 10 | + new_maven_url = "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar" |
| 11 | + open(url) do |f| |
| 12 | + content = f.read |
| 13 | + if !content.nil? && content.include?(new_maven_url) |
| 14 | + puts "[OK]" |
| 15 | + else |
| 16 | + puts "[ERROR]" |
| 17 | + puts "> #{url} not yet updated with #{new_maven_url}" |
| 18 | + end |
| 19 | + end |
| 20 | +end |
| 21 | + |
| 22 | +def check_openapi_generator_online_docker |
| 23 | + print "Checking openapi-generator-online docker ... " |
| 24 | + |
| 25 | + url = "https://hub.docker.com/r/openapitools/openapi-generator-online/tags/" |
| 26 | + docker_tag = "v#{$version}" |
| 27 | + open(url) do |f| |
| 28 | + content = f.read |
| 29 | + if !content.nil? && content.include?(docker_tag) |
| 30 | + puts "[OK]" |
| 31 | + else |
| 32 | + puts "[ERROR]" |
| 33 | + puts "> #{url} does not have tag #{docker_tag}" |
| 34 | + end |
| 35 | + end |
| 36 | +end |
| 37 | + |
| 38 | +def check_openapi_generator_cli_docker |
| 39 | + print "Checking openapi-generator-cli docker ... " |
| 40 | + |
| 41 | + url = "https://hub.docker.com/r/openapitools/openapi-generator-cli/tags/" |
| 42 | + docker_tag = "v#{$version}" |
| 43 | + open(url) do |f| |
| 44 | + content = f.read |
| 45 | + if !content.nil? && content.include?(docker_tag) |
| 46 | + puts "[OK]" |
| 47 | + else |
| 48 | + puts "[ERROR]" |
| 49 | + puts "> #{url} does not have tag #{docker_tag}" |
| 50 | + end |
| 51 | + end |
| 52 | +end |
| 53 | + |
| 54 | +def check_readme |
| 55 | + print "Checking openapi-generator README.md ... " |
| 56 | + |
| 57 | + url = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/README.md" |
| 58 | + matches = ["[#{$version}](https://github.com/OpenAPITools/openapi-generator/releases/tag/v#{$version})", |
| 59 | + "JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar`", |
| 60 | + "wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar -O openapi-generator-cli.jar", |
| 61 | + "Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"] |
| 62 | + open(url) do |f| |
| 63 | + content = f.read |
| 64 | + has_outdated = false |
| 65 | + not_matched = [] |
| 66 | + matches.each do |match| |
| 67 | + if !content.nil? && content.include?(match) |
| 68 | + # matched |
| 69 | + else |
| 70 | + has_outdated = true |
| 71 | + not_matched << match |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + if has_outdated |
| 76 | + puts "[ERROR]" |
| 77 | + not_matched.each do |str| |
| 78 | + puts "> '#{str}' not found in README.md" |
| 79 | + end |
| 80 | + else |
| 81 | + puts "[OK]" |
| 82 | + end |
| 83 | + end |
| 84 | +end |
| 85 | + |
| 86 | +def check_openapi_generator_jar |
| 87 | + print "Checking openapi-generator JAR ... " |
| 88 | + url = "http://central.maven.org/maven2/org/openapitools/openapi-generator/#{$version}/openapi-generator-#{$version}.jar" |
| 89 | + |
| 90 | + if check_url(url) |
| 91 | + puts "[OK]" |
| 92 | + else |
| 93 | + puts "[ERROR]" |
| 94 | + puts "> #{url} not found" |
| 95 | + end |
| 96 | + |
| 97 | +end |
| 98 | + |
| 99 | + |
| 100 | +def check_openapi_generator_cli_jar |
| 101 | + print "Checking openapi-generator-cli JAR ... " |
| 102 | + url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar" |
| 103 | + |
| 104 | + if check_url(url) |
| 105 | + puts "[OK]" |
| 106 | + else |
| 107 | + puts "[ERROR]" |
| 108 | + puts "> #{url} not found" |
| 109 | + end |
| 110 | +end |
| 111 | + |
| 112 | +def check_openapi_generator_maven_plugin_jar |
| 113 | + print "Checking openapi-generator-maven-plugin JAR ... " |
| 114 | + url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-maven-plugin/#{$version}/openapi-generator-maven-plugin-#{$version}.jar" |
| 115 | + |
| 116 | + if check_url(url) |
| 117 | + puts "[OK]" |
| 118 | + else |
| 119 | + puts "[ERROR]" |
| 120 | + puts "> #{url} not found" |
| 121 | + end |
| 122 | +end |
| 123 | + |
| 124 | +def check_openapi_generator_gradle_plugin_jar |
| 125 | + print "Checking openapi-generator-gradle-plugin JAR ... " |
| 126 | + url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-gradle-plugin/#{$version}/openapi-generator-gradle-plugin-#{$version}.jar" |
| 127 | + |
| 128 | + if check_url(url) |
| 129 | + puts "[OK]" |
| 130 | + else |
| 131 | + puts "[ERROR]" |
| 132 | + puts "> #{url} not found" |
| 133 | + end |
| 134 | +end |
| 135 | + |
| 136 | +def check_openapi_generator_online_jar |
| 137 | + print "Checking openapi-generator-online JAR ... " |
| 138 | + url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-online/#{$version}/openapi-generator-online-#{$version}.jar" |
| 139 | + |
| 140 | + if check_url(url) |
| 141 | + puts "[OK]" |
| 142 | + else |
| 143 | + puts "[ERROR]" |
| 144 | + puts "> #{url} not found" |
| 145 | + end |
| 146 | +end |
| 147 | + |
| 148 | +def check_openapi_generator_project_pom |
| 149 | + print "Checking openapi-generator-project pom.xml ... " |
| 150 | + url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-project/#{$version}/openapi-generator-project-#{$version}.pom" |
| 151 | + |
| 152 | + if check_url(url) |
| 153 | + puts "[OK]" |
| 154 | + else |
| 155 | + puts "[ERROR]" |
| 156 | + puts "> #{url} not found" |
| 157 | + end |
| 158 | +end |
| 159 | + |
| 160 | +def check_url url |
| 161 | + content = Net::HTTP.get(URI.parse(url)) |
| 162 | + url = URI.parse(url) |
| 163 | + req = Net::HTTP.new(url.host, url.port) |
| 164 | + res = req.request_head(url.path) |
| 165 | + if res.code == "200" |
| 166 | + true |
| 167 | + else |
| 168 | + false |
| 169 | + end |
| 170 | +end |
| 171 | + |
| 172 | +def usage |
| 173 | + puts "ERROR!! Version (e.g. 3.0.2) missing" |
| 174 | + puts "Usage example: ruby #{$0} 3.0.2" |
| 175 | +end |
| 176 | + |
| 177 | + |
| 178 | +if (!ARGV[0]) |
| 179 | + usage |
| 180 | + exit |
| 181 | +end |
| 182 | + |
| 183 | +$version = ARGV[0] |
| 184 | + |
| 185 | +puts "Running checkout on OpenAPI Generator release #{$version}" |
| 186 | + |
| 187 | +check_homebrew |
| 188 | +check_openapi_generator_jar |
| 189 | +check_openapi_generator_cli_jar |
| 190 | +check_openapi_generator_maven_plugin_jar |
| 191 | +check_openapi_generator_gradle_plugin_jar |
| 192 | +check_openapi_generator_online_jar |
| 193 | +check_openapi_generator_project_pom |
| 194 | +check_readme |
| 195 | +check_openapi_generator_online_docker |
| 196 | +check_openapi_generator_cli_docker |
0 commit comments