mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 02:56:38 +02:00
🎉 Add version string parsing.
This commit is contained in:
parent
ac2310f71f
commit
28a2df96ff
6 changed files with 72 additions and 29 deletions
|
@ -11,6 +11,7 @@
|
||||||
"A configuration management."
|
"A configuration management."
|
||||||
(:require
|
(:require
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
|
[app.common.version :as v]
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
|
@ -197,6 +198,9 @@
|
||||||
(def default-deletion-delay
|
(def default-deletion-delay
|
||||||
(dt/duration {:hours 48}))
|
(dt/duration {:hours 48}))
|
||||||
|
|
||||||
|
(def version
|
||||||
|
(delay (v/parse "%version%")))
|
||||||
|
|
||||||
(defn smtp
|
(defn smtp
|
||||||
[cfg]
|
[cfg]
|
||||||
{:host (:smtp-host cfg "localhost")
|
{:host (:smtp-host cfg "localhost")
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
(ns app.main
|
(ns app.main
|
||||||
(:require
|
(:require
|
||||||
|
[app.config :as cfg]
|
||||||
|
[clojure.tools.logging :as log]
|
||||||
[mount.core :as mount]))
|
[mount.core :as mount]))
|
||||||
|
|
||||||
(defn- enable-asserts
|
(defn- enable-asserts
|
||||||
|
@ -26,15 +28,13 @@
|
||||||
|
|
||||||
(defn run
|
(defn run
|
||||||
[_params]
|
[_params]
|
||||||
(require 'app.config
|
(require 'app.srepl.server
|
||||||
'app.srepl.server
|
|
||||||
'app.migrations
|
'app.migrations
|
||||||
'app.worker
|
'app.worker
|
||||||
'app.media
|
'app.media
|
||||||
'app.http)
|
'app.http)
|
||||||
(mount/start))
|
(mount/start)
|
||||||
|
(log/infof "Welcome to penpot! Version: '%s'." (:full @cfg/version)))
|
||||||
|
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& _args]
|
[& _args]
|
||||||
|
|
18
common/app/common/version.cljc
Normal file
18
common/app/common/version.cljc
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
(ns app.common.version
|
||||||
|
"A version parsing helper."
|
||||||
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
|
(defn parse
|
||||||
|
[version]
|
||||||
|
(if (= version "%version%")
|
||||||
|
{:full "develop"
|
||||||
|
:base "develop"
|
||||||
|
:build 0
|
||||||
|
:commit nil}
|
||||||
|
(let [[base build commit] (str/split version #"-" 3)]
|
||||||
|
{:full version
|
||||||
|
:base base
|
||||||
|
:build (d/parse-integer build)
|
||||||
|
:commit commit})))
|
|
@ -6,21 +6,27 @@
|
||||||
<title>PENPOT - The Open-Source prototyping tool</title>
|
<title>PENPOT - The Open-Source prototyping tool</title>
|
||||||
<link id="theme" href="/css/main-{{& th}}.css?ts={{& ts}}"
|
<link id="theme" href="/css/main-{{& th}}.css?ts={{& ts}}"
|
||||||
rel="stylesheet" type="text/css" />
|
rel="stylesheet" type="text/css" />
|
||||||
|
|
||||||
<link rel="icon" href="/images/favicon.png" />
|
<link rel="icon" href="/images/favicon.png" />
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{{>../public/images/sprites/symbol/svg/sprite.symbol.svg}}
|
|
||||||
<section id="app" tabindex="1"></section>
|
|
||||||
<section id="modal"></section>
|
|
||||||
<script>
|
<script>
|
||||||
window.appTranslations = JSON.parse({{& translations}});
|
window.appTranslations = JSON.parse({{& translations}});
|
||||||
window.appThemes = {{& themes}};
|
window.appThemes = {{& themes}};
|
||||||
|
window.appVersion = "%version%";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{# manifest}}
|
{{# manifest}}
|
||||||
<script>window.appWorkerURI="{{& worker}}"</script>
|
<script>window.appWorkerURI="{{& worker}}"</script>
|
||||||
<script src="{{& config}}"></script>
|
<script src="{{& config}}"></script>
|
||||||
<script src="{{& polyfills}}"></script>
|
<script src="{{& polyfills}}"></script>
|
||||||
|
{{/manifest}}
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{>../public/images/sprites/symbol/svg/sprite.symbol.svg}}
|
||||||
|
<section id="app" tabindex="1"></section>
|
||||||
|
<section id="modal"></section>
|
||||||
|
{{# manifest}}
|
||||||
<script src="{{& shared}}"></script>
|
<script src="{{& shared}}"></script>
|
||||||
<script src="{{& main}}"></script>
|
<script src="{{& main}}"></script>
|
||||||
{{/manifest}}
|
{{/manifest}}
|
||||||
|
|
|
@ -10,15 +10,19 @@
|
||||||
(ns app.config
|
(ns app.config
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
[app.common.data :as d]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
|
[app.common.version :as v]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
|
;; --- Auxiliar Functions
|
||||||
|
|
||||||
(s/def ::platform #{:windows :linux :macos :other})
|
(s/def ::platform #{:windows :linux :macos :other})
|
||||||
(s/def ::browser #{:chrome :mozilla :safari :edge :other})
|
(s/def ::browser #{:chrome :mozilla :safari :edge :other})
|
||||||
|
|
||||||
(defn parse-browser
|
(defn- parse-browser
|
||||||
[]
|
[]
|
||||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||||
check-chrome? (fn [] (str/includes? user-agent "chrom"))
|
check-chrome? (fn [] (str/includes? user-agent "chrom"))
|
||||||
|
@ -32,7 +36,7 @@
|
||||||
(check-safari?) :safari
|
(check-safari?) :safari
|
||||||
:else :other)))
|
:else :other)))
|
||||||
|
|
||||||
(defn parse-platform
|
(defn- parse-platform
|
||||||
[]
|
[]
|
||||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||||
check-windows? (fn [] (str/includes? user-agent "windows"))
|
check-windows? (fn [] (str/includes? user-agent "windows"))
|
||||||
|
@ -44,6 +48,10 @@
|
||||||
(check-macos?) :macos
|
(check-macos?) :macos
|
||||||
:else :other)))
|
:else :other)))
|
||||||
|
|
||||||
|
;; --- Globar Config Vars
|
||||||
|
|
||||||
|
(def default-theme "default")
|
||||||
|
|
||||||
(this-as global
|
(this-as global
|
||||||
(def default-language "en")
|
(def default-language "en")
|
||||||
(def demo-warning (obj/get global "appDemoWarning" false))
|
(def demo-warning (obj/get global "appDemoWarning" false))
|
||||||
|
@ -53,10 +61,18 @@
|
||||||
(def worker-uri (obj/get global "appWorkerURI" "/js/worker.js"))
|
(def worker-uri (obj/get global "appWorkerURI" "/js/worker.js"))
|
||||||
(def public-uri (or (obj/get global "appPublicURI")
|
(def public-uri (or (obj/get global "appPublicURI")
|
||||||
(.-origin ^js js/location)))
|
(.-origin ^js js/location)))
|
||||||
(def media-uri (str public-uri "/media"))
|
(def version (v/parse (obj/get global "appVersion"))))
|
||||||
(def default-theme "default")
|
|
||||||
(def browser (parse-browser))
|
|
||||||
(def platform (parse-platform)))
|
(def media-uri (str public-uri "/media"))
|
||||||
|
(def browser (parse-browser))
|
||||||
|
(def platform (parse-platform))
|
||||||
|
|
||||||
|
(js/console.log
|
||||||
|
(str/format "Welcome to pentpot! Version: '%s'" (:full version)))
|
||||||
|
|
||||||
|
;; --- Helper Functions
|
||||||
|
|
||||||
|
|
||||||
(defn ^boolean check-browser? [candidate]
|
(defn ^boolean check-browser? [candidate]
|
||||||
(us/verify ::browser candidate)
|
(us/verify ::browser candidate)
|
||||||
|
|
21
manage.sh
21
manage.sh
|
@ -6,7 +6,7 @@ export DEVENV_IMGNAME="$ORGANIZATION/devenv";
|
||||||
export DEVENV_PNAME="penpotdev";
|
export DEVENV_PNAME="penpotdev";
|
||||||
|
|
||||||
export CURRENT_USER_ID=$(id -u);
|
export CURRENT_USER_ID=$(id -u);
|
||||||
export CURRENT_GIT_TAG=$(git describe --tags);
|
export CURRENT_VERSION=$(git describe --tags);
|
||||||
export CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
|
export CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
|
||||||
|
|
||||||
function build-devenv {
|
function build-devenv {
|
||||||
|
@ -95,12 +95,11 @@ function build-bundle {
|
||||||
mv ./backend/target/dist ./bundle/backend
|
mv ./backend/target/dist ./bundle/backend
|
||||||
mv ./exporter/target ./bundle/exporter
|
mv ./exporter/target ./bundle/exporter
|
||||||
|
|
||||||
local name="penpot-$CURRENT_GIT_TAG";
|
local name="penpot-$CURRENT_VERSION";
|
||||||
|
echo $CURRENT_VERSION > ./bundle/version.txt
|
||||||
|
|
||||||
echo $CURRENT_GIT_TAG > ./bundle/frontend/version.txt
|
sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./bundle/frontend/index.html;
|
||||||
echo $CURRENT_GIT_TAG > ./bundle/backend/main/version.txt
|
sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./bundle/backend/main/app/config.clj;
|
||||||
echo $CURRENT_GIT_TAG > ./bundle/exporter/version.txt
|
|
||||||
echo $CURRENT_GIT_TAG > ./bundle/version.txt
|
|
||||||
|
|
||||||
local generate_tar=${PENPOT_BUILD_GENERATE_TAR:-"true"};
|
local generate_tar=${PENPOT_BUILD_GENERATE_TAR:-"true"};
|
||||||
|
|
||||||
|
@ -124,12 +123,12 @@ function build-image {
|
||||||
|
|
||||||
pushd ./docker/images;
|
pushd ./docker/images;
|
||||||
local docker_image="$ORGANIZATION/$image";
|
local docker_image="$ORGANIZATION/$image";
|
||||||
docker build -t $docker_image:$CURRENT_GIT_TAG -f Dockerfile.$image .;
|
docker build -t $docker_image:$CURRENT_VERSION -f Dockerfile.$image .;
|
||||||
popd;
|
popd;
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-images {
|
function build-images {
|
||||||
local bundle_file="penpot-$CURRENT_GIT_TAG.tar.xz";
|
local bundle_file="penpot-$CURRENT_VERSION.tar.xz";
|
||||||
|
|
||||||
if [ ! -f $bundle_file ]; then
|
if [ ! -f $bundle_file ]; then
|
||||||
echo "File '$bundle_file' does not exists.";
|
echo "File '$bundle_file' does not exists.";
|
||||||
|
@ -153,9 +152,9 @@ function build-images {
|
||||||
|
|
||||||
function publish-snapshot {
|
function publish-snapshot {
|
||||||
set -x
|
set -x
|
||||||
docker tag $ORGANIZATION/frontend:$CURRENT_GIT_TAG $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH
|
docker tag $ORGANIZATION/frontend:$CURRENT_VERSION $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH
|
||||||
docker tag $ORGANIZATION/backend:$CURRENT_GIT_TAG $ORGANIZATION/backend:$CURRENT_GIT_BRANCH
|
docker tag $ORGANIZATION/backend:$CURRENT_VERSION $ORGANIZATION/backend:$CURRENT_GIT_BRANCH
|
||||||
docker tag $ORGANIZATION/exporter:$CURRENT_GIT_TAG $ORGANIZATION/exporter:$CURRENT_GIT_BRANCH
|
docker tag $ORGANIZATION/exporter:$CURRENT_VERSION $ORGANIZATION/exporter:$CURRENT_GIT_BRANCH
|
||||||
|
|
||||||
docker push $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH;
|
docker push $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH;
|
||||||
docker push $ORGANIZATION/backend:$CURRENT_GIT_BRANCH;
|
docker push $ORGANIZATION/backend:$CURRENT_GIT_BRANCH;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue