diff --git a/.circleci/script/gen_ci.clj b/.circleci/script/gen_ci.clj index 6922d8fe..ae0b9675 100644 --- a/.circleci/script/gen_ci.clj +++ b/.circleci/script/gen_ci.clj @@ -84,7 +84,8 @@ :BABASHKA_PLATFORM "linux" :GRAALVM_VERSION graalvm-version :GRAALVM_HOME graalvm-home - :BABASHKA_TEST_ENV "jvm"} + :BABASHKA_TEST_ENV "jvm" + :BABASHKA_SHA (System/getenv "CIRCLE_SHA1")} :resource_class "large" :steps (gen-steps @@ -128,7 +129,8 @@ java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$refl "macos" platform) :BABASHKA_TEST_ENV "native" - :BABASHKA_XMX "-J-Xmx6500m"} + :BABASHKA_XMX "-J-Xmx6500m" + :BABASHKA_SHA (System/getenv "CIRCLE_SHA1")} env (if (= "aarch64" arch) (assoc env :BABASHKA_ARCH arch) env) diff --git a/.cirrus.yml b/.cirrus.yml index 54d93672..3e36b348 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,6 +24,8 @@ task: sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license java -version + export BABASHKA_SHA=$(git rev-parse HEAD) + script/uberjar # curl -sLO 'https://github.com/babashka/pgo-profiles/releases/download/2023.10.11/default.iprof' script/compile # --pgo=default.iprof diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d90c5d83..a836a934 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,7 @@ jobs: LEIN_ROOT: "true" BABASHKA_PLATFORM: linux # could be used in jar name GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BABASHKA_SHA: ${{ github.sha }} steps: - name: Git checkout uses: actions/checkout@v2 @@ -107,6 +108,7 @@ jobs: BABASHKA_TEST_ENV: native BABASHKA_XMX: "-J-Xmx6500m" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BABASHKA_SHA: ${{ github.sha }} steps: - name: Git checkout uses: actions/checkout@v2 diff --git a/appveyor.yml b/appveyor.yml index 37817a29..59c901ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -61,6 +61,8 @@ build_script: # see https://github.com/quarkusio/quarkus/pull/7663 - cmd: >- + set BABASHKA_SHA=%APPVEYOR_REPO_COMMIT% + call script/uberjar.bat call script/compile.bat diff --git a/resources/META-INF/native-image/babashka/babashka/native-image.properties b/resources/META-INF/native-image/babashka/babashka/native-image.properties index ea2ccd7e..f6db946b 100644 --- a/resources/META-INF/native-image/babashka/babashka/native-image.properties +++ b/resources/META-INF/native-image/babashka/babashka/native-image.properties @@ -53,4 +53,5 @@ Args=-H:+ReportExceptionStackTraces \ -EBABASHKA_FEATURE_LANTERNA \ -EBABASHKA_FEATURE_SPEC_ALPHA \ -EBABASHKA_FEATURE_RRB_VECTOR \ - -EBABASHKA_REQUIRE_SCAN + -EBABASHKA_REQUIRE_SCAN \ + -EBABASHKA_SHA diff --git a/script/compile b/script/compile index d1f1cc57..05dc65dc 100755 --- a/script/compile +++ b/script/compile @@ -107,4 +107,14 @@ then export BABASHKA_FEATURE_PRIORITY_MAP="${BABASHKA_FEATURE_PRIORITY_MAP:-false}" fi +if [[ -z "$BABASHKA_SHA" ]] +then + sha=$(git rev-parse HEAD) + if [[ $? -eq 0 ]]; then + export BABASHKA_SHA=$sha + fi +fi + "$GRAALVM_HOME/bin/native-image" "${args[@]}" "$@" + +./"$BABASHKA_BINARY" describe diff --git a/script/compile.bat b/script/compile.bat index 51abbc72..a78af136 100644 --- a/script/compile.bat +++ b/script/compile.bat @@ -23,6 +23,13 @@ Rem -H:EnableURLProtocols=jar,http,https is also not supported. call %GRAALVM_HOME%\bin\gu.cmd install native-image +if "%BABASHKA_SHA%"=="" ( + for /f %%i in ('git rev-parse HEAD') do set sha=%%i + if not errorlevel 1 ( + set BABASHKA_SHA=%sha% + ) +) + call %GRAALVM_HOME%\bin\native-image.cmd ^ "-jar" "target/babashka-%BABASHKA_VERSION%-standalone.jar" ^ "-H:Name=bb" ^ @@ -39,3 +46,4 @@ call %GRAALVM_HOME%\bin\native-image.cmd ^ if %errorlevel% neq 0 exit /b %errorlevel% call bb "(+ 1 2 3)" +call bb describe diff --git a/src/babashka/main.clj b/src/babashka/main.clj index d4d012e0..831f562c 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -110,6 +110,8 @@ (def version common/version) +(def build-commit-sha (or (System/getenv "BABASHKA_SHA") "")) + (defn parse-version [version] (mapv #(Integer/parseInt %) (-> version @@ -261,6 +263,7 @@ Use bb run --help to show this help output. (format (str/trim " {:babashka/version \"%s\" + :git/sha \"%s\" :feature/csv %s :feature/java-nio %s :feature/java-time %s @@ -281,6 +284,7 @@ Use bb run --help to show this help output. :feature/logging %s :feature/priority-map %s}") version + build-commit-sha features/csv? features/java-nio? features/java-time?