2020-05-22 14:13:00 +00:00
|
|
|
#!/usr/bin/env bb
|
|
|
|
|
|
|
|
|
|
;; NOTE
|
2020-05-23 12:53:28 +00:00
|
|
|
;;
|
2020-05-22 14:13:00 +00:00
|
|
|
;; For more information on the current scene on support for
|
|
|
|
|
;; particular GraalVM versions, look here: https://www.graalvm.org/downloads/
|
2020-05-23 12:53:28 +00:00
|
|
|
;;
|
2020-05-22 14:13:00 +00:00
|
|
|
;; There are 4 CE(Community Editions) being supported by GraalVM
|
|
|
|
|
;; GraalVM Community Edition 20.1.0 based on OpenJDK 8u252
|
|
|
|
|
;; GraalVM Community Edition 20.1.0 based on OpenJDK 11.0.7
|
|
|
|
|
;; GraalVM Community Edition 19.3.2 based on OpenJDK 8u252
|
|
|
|
|
;; GraalVM Community Edition 19.3.2 based on OpenJDK 11.0.7
|
2020-05-23 12:53:28 +00:00
|
|
|
;;
|
2023-02-21 15:23:03 +00:00
|
|
|
;; Currently we use GraalVM java19-20.1.0
|
2020-05-22 14:13:00 +00:00
|
|
|
|
|
|
|
|
(ns bump-graal-version
|
|
|
|
|
(:require [clojure.string :as str]
|
|
|
|
|
[clojure.tools.cli :as cli]))
|
|
|
|
|
|
|
|
|
|
(defn display-help []
|
|
|
|
|
(println (->> [""
|
|
|
|
|
"This is a script that should be run when you'd"
|
|
|
|
|
"you'd like to bump the GraalVM/java version for bb."
|
|
|
|
|
""
|
|
|
|
|
"The following options are available:"
|
|
|
|
|
"(-g, --graal) - to specify the GraalVM version"
|
|
|
|
|
"(-j, --java) - to specify the java version"
|
|
|
|
|
""
|
|
|
|
|
"Use it by providing one or 2 command line arguments"
|
|
|
|
|
"i.e the version you'd want to upgrade it to and/or the java version"
|
|
|
|
|
""
|
|
|
|
|
"./bump_graal_version.clj -g 19.3.2 (the new version)"
|
|
|
|
|
"or"
|
2023-02-21 15:23:03 +00:00
|
|
|
"./bump_graal_version.clj -g 19.3.2 --java java19"
|
|
|
|
|
"(for GraalVM java19-19.3.2)"
|
2020-05-22 14:13:00 +00:00
|
|
|
""]
|
|
|
|
|
(str/join \newline))))
|
|
|
|
|
|
|
|
|
|
(def files-to-edit
|
2020-05-23 13:57:27 +00:00
|
|
|
["Dockerfile"
|
2020-05-23 14:27:02 +00:00
|
|
|
"doc/dev.md"
|
2020-12-04 08:42:24 +00:00
|
|
|
"doc/build.md"
|
2020-05-23 13:57:27 +00:00
|
|
|
".github/workflows/build.yml"
|
2020-05-22 14:13:00 +00:00
|
|
|
".circleci/config.yml"
|
2020-09-18 19:32:08 +00:00
|
|
|
"appveyor.yml"
|
2022-07-27 10:20:32 +00:00
|
|
|
"project.clj"
|
|
|
|
|
"script/bump_graal_version.clj"
|
2024-10-12 09:28:58 +00:00
|
|
|
".cirrus.yml"
|
|
|
|
|
"script/install-graalvm"])
|
2020-05-22 14:13:00 +00:00
|
|
|
|
|
|
|
|
;; We might have to keep changing these from
|
|
|
|
|
;; time to time whenever the version is bumped
|
2020-05-23 12:53:28 +00:00
|
|
|
;;
|
|
|
|
|
;; OR
|
|
|
|
|
;;
|
2020-05-22 14:13:00 +00:00
|
|
|
;; We could have them as environment variables
|
2025-03-19 15:38:17 +00:00
|
|
|
(def current-graal-version "24")
|
2020-05-22 14:13:00 +00:00
|
|
|
|
|
|
|
|
(def cl-options
|
|
|
|
|
[["-g" "--graal VERSION" "graal version"]
|
|
|
|
|
["-j" "--java VERSION" "java version"]
|
|
|
|
|
["-h" "--help"]])
|
|
|
|
|
|
|
|
|
|
(def cl-args
|
|
|
|
|
(:options (cli/parse-opts *command-line-args* cl-options)))
|
|
|
|
|
|
|
|
|
|
(defn is-valid-bump?
|
2022-07-27 10:20:32 +00:00
|
|
|
[_version _valid-bumps]
|
|
|
|
|
true)
|
2020-05-22 14:13:00 +00:00
|
|
|
|
|
|
|
|
(defn replace-current
|
|
|
|
|
[file current new]
|
|
|
|
|
(let [file-contents (slurp file)]
|
|
|
|
|
(str/replace file-contents current new)))
|
|
|
|
|
|
|
|
|
|
(defn bump-current
|
|
|
|
|
[current new]
|
2020-05-23 12:53:28 +00:00
|
|
|
(doseq [file files-to-edit]
|
|
|
|
|
(let [exec-res (replace-current file current new)]
|
|
|
|
|
(try (spit file exec-res)
|
|
|
|
|
(catch Exception e (str "There was an error: " (.getMessage e)))
|
|
|
|
|
(finally
|
|
|
|
|
(println "Done with : " file))))))
|
2020-05-22 14:13:00 +00:00
|
|
|
|
|
|
|
|
(defn show-error
|
|
|
|
|
[err-version]
|
|
|
|
|
(println "This is not a valid version: " err-version))
|
|
|
|
|
|
|
|
|
|
(defn exec-script
|
|
|
|
|
[args]
|
|
|
|
|
(when (empty? args)
|
|
|
|
|
(display-help))
|
2024-10-12 09:28:58 +00:00
|
|
|
(let [new-graal-version (:graal args)]
|
2020-05-22 14:13:00 +00:00
|
|
|
(when (not (nil? new-graal-version))
|
2022-07-27 10:20:32 +00:00
|
|
|
(if (is-valid-bump? new-graal-version nil)
|
2020-05-22 14:13:00 +00:00
|
|
|
(do
|
|
|
|
|
(println "Performing Graal bump...")
|
|
|
|
|
(bump-current current-graal-version new-graal-version))
|
2024-10-12 09:28:58 +00:00
|
|
|
(show-error new-graal-version)))))
|
2020-05-22 14:13:00 +00:00
|
|
|
|
|
|
|
|
(exec-script cl-args)
|