From 159f1962a18811b885a4180650318a98feaf61a1 Mon Sep 17 00:00:00 2001 From: James Salter Date: Tue, 7 Dec 2021 15:35:23 +1100 Subject: [PATCH 1/6] Fix Docker build versioning (#20077) (#20078) * Centralise version scripts and fix Docker version * Refactor generation of a git-hash-based version into get-version-from-git * Refactor normalization of versions (stripping leading v) into normalize-version.sh * Call get-version-from-git from ci_package.sh, call normalize-version from package.sh * Refactor docker-write-version.sh into docker-package.sh, which both writes the version file and invokes yarn build passing VERSION * Normalize the version received from the server --- Dockerfile | 7 ++----- scripts/ci_package.sh | 12 +++-------- ...ker-write-version.sh => docker-package.sh} | 7 +++---- scripts/get-version-from-git.sh | 10 +++++++++ scripts/normalize-version.sh | 8 +++++++ scripts/package.sh | 7 +------ src/vector/platform/WebPlatform.ts | 21 ++++++++----------- 7 files changed, 36 insertions(+), 36 deletions(-) rename scripts/{docker-write-version.sh => docker-package.sh} (65%) mode change 100644 => 100755 create mode 100755 scripts/get-version-from-git.sh create mode 100755 scripts/normalize-version.sh diff --git a/Dockerfile b/Dockerfile index 601f2cdbb..d33e1d845 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,15 +16,12 @@ WORKDIR /src COPY . /src RUN dos2unix /src/scripts/docker-link-repos.sh && bash /src/scripts/docker-link-repos.sh RUN yarn --network-timeout=100000 install -RUN yarn build + +RUN dos2unix /src/scripts/docker-package.sh && bash /src/scripts/docker-package.sh # Copy the config now so that we don't create another layer in the app image RUN cp /src/config.sample.json /src/webapp/config.json -# Ensure we populate the version file -RUN dos2unix /src/scripts/docker-write-version.sh && bash /src/scripts/docker-write-version.sh - - # App FROM nginx:alpine diff --git a/scripts/ci_package.sh b/scripts/ci_package.sh index 41d82016e..72ae5f3a4 100755 --- a/scripts/ci_package.sh +++ b/scripts/ci_package.sh @@ -1,17 +1,11 @@ #!/bin/bash -# Runs package.sh setting the version to git hashes of the element-web, -# react-sdk & js-sdk checkouts, for the case where these dependencies -# are git checkouts. +# Runs package.sh, passing DIST_VERSION determined by git set -ex rm dist/element-*.tar.gz || true # rm previous artifacts without failing if it doesn't exist -# Since the deps are fetched from git, we can rev-parse -REACT_SHA=$(cd node_modules/matrix-react-sdk; git rev-parse --short=12 HEAD) -JSSDK_SHA=$(cd node_modules/matrix-js-sdk; git rev-parse --short=12 HEAD) +DIST_VERSION=`$(dirname $0)/get-version-from-git.sh` -VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop - -CI_PACKAGE=true DIST_VERSION=$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA scripts/package.sh +CI_PACKAGE=true DIST_VERSION=$DIST_VERSION scripts/package.sh diff --git a/scripts/docker-write-version.sh b/scripts/docker-package.sh old mode 100644 new mode 100755 similarity index 65% rename from scripts/docker-write-version.sh rename to scripts/docker-package.sh index 87014b4ff..f1bb99abf --- a/scripts/docker-write-version.sh +++ b/scripts/docker-package.sh @@ -13,10 +13,9 @@ DIST_VERSION=$TAG # for an appropriately tagged branch as well (heads/v1.2.3). if [[ $BRANCH != HEAD && ! $BRANCH =~ heads/v.+ ]] then - REACT_SHA=$(cd node_modules/matrix-react-sdk; git rev-parse --short=12 HEAD) - JSSDK_SHA=$(cd node_modules/matrix-js-sdk; git rev-parse --short=12 HEAD) - VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop - DIST_VERSION=$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA + DIST_VERSION=`$(dirname $0)/get-version-from-git.sh` fi +DIST_VERSION=`$(dirname $0)/normalize-version.sh ${DIST_VERSION}` +VERSION=$DIST_VERSION yarn build echo $DIST_VERSION > /src/webapp/version diff --git a/scripts/get-version-from-git.sh b/scripts/get-version-from-git.sh new file mode 100755 index 000000000..f3abdcb7c --- /dev/null +++ b/scripts/get-version-from-git.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Echoes a version based on the git hashes of the element-web, react-sdk & js-sdk checkouts, for the case where +# these dependencies are git checkouts. + +# Since the deps are fetched from git, we can rev-parse +REACT_SHA=$(cd node_modules/matrix-react-sdk; git rev-parse --short=12 HEAD) +JSSDK_SHA=$(cd node_modules/matrix-js-sdk; git rev-parse --short=12 HEAD) +VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop +echo $VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA diff --git a/scripts/normalize-version.sh b/scripts/normalize-version.sh new file mode 100755 index 000000000..d8a68bebd --- /dev/null +++ b/scripts/normalize-version.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# If $1 looks like v1.2.3 or v1.2.3-foo, strip the leading v, then print it to stdout +if [[ $1 =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-.+)?$ ]]; then + echo ${1:1} +else + echo $1 +fi diff --git a/scripts/package.sh b/scripts/package.sh index b7c27755d..9f95e87f1 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -21,12 +21,7 @@ cp -r webapp element-$version # Just in case you have a local config, remove it before packaging rm element-$version/config.json || true -# if $version looks like semver with leading v, strip it before writing to file -if [[ ${version} =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-.+)?$ ]]; then - echo ${version:1} > element-$version/version -else - echo ${version} > element-$version/version -fi +$(dirname $0)/normalize-version.sh ${version} > element-$version/version tar chvzf dist/element-$version.tar.gz element-$version rm -r element-$version diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index f3f3d55ac..439ee31c4 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -107,7 +107,7 @@ export default class WebPlatform extends VectorBasePlatform { // presence of intermediate caching proxies), but still: we're trying // to tell the user that there is a new version. - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { request( { method: "GET", @@ -121,27 +121,24 @@ export default class WebPlatform extends VectorBasePlatform { return; } - const ver = body.trim(); - resolve(ver); + resolve(this.getNormalizedAppVersion(body.trim())); }, ); }); } - getNormalizedAppVersion(): string { - let ver = process.env.VERSION; - + getNormalizedAppVersion(version: string): string { // if version looks like semver with leading v, strip it - // (matches scripts/package.sh) + // (matches scripts/normalize-version.sh) const semVerRegex = new RegExp("^v[0-9]+.[0-9]+.[0-9]+(-.+)?$"); - if (semVerRegex.test(process.env.VERSION)) { - ver = process.env.VERSION.substr(1); + if (semVerRegex.test(version)) { + return version.substr(1); } - return ver; + return version; } getAppVersion(): Promise { - return Promise.resolve(this.getNormalizedAppVersion()); + return Promise.resolve(this.getNormalizedAppVersion(process.env.VERSION)); } startUpdater() { @@ -155,7 +152,7 @@ export default class WebPlatform extends VectorBasePlatform { pollForUpdate = () => { return this.getMostRecentVersion().then((mostRecentVersion) => { - const currentVersion = this.getNormalizedAppVersion(); + const currentVersion = this.getNormalizedAppVersion(process.env.VERSION); if (currentVersion !== mostRecentVersion) { if (this.shouldShowUpdate(mostRecentVersion)) { From 0637c2e74d77c8e7de1a1c190763f6543bf10cee Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 13 Dec 2021 14:59:21 +0000 Subject: [PATCH 2/6] update olm to 3.2.8 (#20160) --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 078c7721e..75ba928c5 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "test": "jest" }, "dependencies": { - "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz", + "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz", "browser-request": "^0.3.3", "gfm.css": "^1.1.2", "jsrsasign": "^10.2.0", diff --git a/yarn.lock b/yarn.lock index 6af1d4aec..967b4ebd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1306,9 +1306,9 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" -"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz": - version "3.2.3" - resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz#cc332fdd25c08ef0e40f4d33fc3f822a0f98b6f4" +"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz": + version "3.2.8" + resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz#8d53636d045e1776e2a2ec6613e57330dd9ce856" "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" From 9eb5af53e22b862cff27e8d1f785c9bda173d112 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 13 Dec 2021 15:32:59 +0000 Subject: [PATCH 3/6] Upgrade matrix-js-sdk to 15.2.1 --- package.json | 2 +- yarn.lock | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 75ba928c5..c864e7514 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "gfm.css": "^1.1.2", "jsrsasign": "^10.2.0", "katex": "^0.12.0", - "matrix-js-sdk": "15.2.0", + "matrix-js-sdk": "15.2.1", "matrix-react-sdk": "3.36.0", "matrix-widget-api": "^0.1.0-beta.17", "prop-types": "^15.7.2", diff --git a/yarn.lock b/yarn.lock index 967b4ebd6..ec88b5898 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7870,6 +7870,22 @@ matrix-js-sdk@15.2.0: request "^2.88.2" unhomoglyph "^1.0.6" +matrix-js-sdk@15.2.1: + version "15.2.1" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-15.2.1.tgz#61e9742ccacfe486231415372e12cb13607b5d7c" + integrity sha512-e0/NE6LUfDLKLdWNFyH5OGt2QHybandrC0x9qgj7P1/fe+zgLGGd8W4XGDa5CMHjjqm/OoLMam44+0+FafojlQ== + dependencies: + "@babel/runtime" "^7.12.5" + another-json "^0.2.0" + browser-request "^0.3.3" + bs58 "^4.0.1" + content-type "^1.0.4" + loglevel "^1.7.1" + p-retry "^4.5.0" + qs "^6.9.6" + request "^2.88.2" + unhomoglyph "^1.0.6" + matrix-mock-request@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/matrix-mock-request/-/matrix-mock-request-1.2.3.tgz#56b15d86e2601a9b48a854844396d18caab649c8" From 80cf11135d7c1377f00e7530c249b3bdc45a7834 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 13 Dec 2021 15:33:35 +0000 Subject: [PATCH 4/6] Upgrade matrix-react-sdk to 3.36.1 --- package.json | 2 +- yarn.lock | 26 +++++--------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index c864e7514..c7474e135 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "jsrsasign": "^10.2.0", "katex": "^0.12.0", "matrix-js-sdk": "15.2.1", - "matrix-react-sdk": "3.36.0", + "matrix-react-sdk": "3.36.1", "matrix-widget-api": "^0.1.0-beta.17", "prop-types": "^15.7.2", "react": "17.0.2", diff --git a/yarn.lock b/yarn.lock index ec88b5898..0333fc59d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7854,22 +7854,6 @@ mathml-tag-names@^2.1.3: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg== -matrix-js-sdk@15.2.0: - version "15.2.0" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-15.2.0.tgz#1f04fe938f951af8af4b78dff8ff697db5981428" - integrity sha512-jZOM8Fn86oNvU3zVQcc+JTKKrtYq4ADN6rPZs4Mwxj/X/GDP+2YIP5176GtviF0GM6VO1dcnPZY73ykl8DayjA== - dependencies: - "@babel/runtime" "^7.12.5" - another-json "^0.2.0" - browser-request "^0.3.3" - bs58 "^4.0.1" - content-type "^1.0.4" - loglevel "^1.7.1" - p-retry "^4.5.0" - qs "^6.9.6" - request "^2.88.2" - unhomoglyph "^1.0.6" - matrix-js-sdk@15.2.1: version "15.2.1" resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-15.2.1.tgz#61e9742ccacfe486231415372e12cb13607b5d7c" @@ -7894,10 +7878,10 @@ matrix-mock-request@^1.2.3: bluebird "^3.5.0" expect "^1.20.2" -matrix-react-sdk@3.36.0: - version "3.36.0" - resolved "https://registry.yarnpkg.com/matrix-react-sdk/-/matrix-react-sdk-3.36.0.tgz#70a07944bd217e8d52e7b818d215d6d7e1b9c3f2" - integrity sha512-/Mc+4PrySGs2LHN15LQk9bUauAHk2dW7SrG04wEnjNSA+yudH5wiHYZ/4p1ZHjOLW/NsDoGpIYN+Yqkr9aKuHA== +matrix-react-sdk@3.36.1: + version "3.36.1" + resolved "https://registry.yarnpkg.com/matrix-react-sdk/-/matrix-react-sdk-3.36.1.tgz#0970b5e707e5dfc07dd708a3e30f7050296fcc31" + integrity sha512-5L6SoMt3S1gjvB4AviR1Duc6sSVqf1hSq7aW8JH1houF3N7cYlNDJL5RXQ+G3iFqMlE+QpEUOApfN45WjLA+Bw== dependencies: "@babel/runtime" "^7.12.5" "@sentry/browser" "^6.11.0" @@ -7928,7 +7912,7 @@ matrix-react-sdk@3.36.0: katex "^0.12.0" linkifyjs "^2.1.9" lodash "^4.17.20" - matrix-js-sdk "15.2.0" + matrix-js-sdk "15.2.1" matrix-widget-api "^0.1.0-beta.17" minimist "^1.2.5" opus-recorder "^8.0.3" From 1b6b1a86216dbf923152e05b966a28109ffd2d52 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 13 Dec 2021 15:36:53 +0000 Subject: [PATCH 5/6] Prepare changelog for v1.9.7 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b7093bc1..752fcedda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Changes in [1.9.7](https://github.com/vector-im/element-web/releases/tag/v1.9.7) (2021-12-13) +============================================================================================= + + * Security release with updated version of Olm to fix https://matrix.org/blog/2021/12/03/pre-disclosure-upcoming-security-release-of-libolm-and-matrix-js-sdk + * Fix a crash on logout + Changes in [1.9.6](https://github.com/vector-im/element-web/releases/tag/v1.9.6) (2021-12-06) ============================================================================================= From eae38311b24da6801366780fe889aafe2d892e9f Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 13 Dec 2021 15:36:54 +0000 Subject: [PATCH 6/6] v1.9.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7474e135..798033d52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "element-web", - "version": "1.9.6", + "version": "1.9.7", "description": "A feature-rich client for Matrix.org", "author": "New Vector Ltd.", "repository": {