|
| 1 | +#!/bin/bash |
| 2 | +#-- copyright |
| 3 | +# OpenProject is a project management system. |
| 4 | +# Copyright (C) the OpenProject GmbH |
| 5 | +# |
| 6 | +# This program is free software; you can redistribute it and/or |
| 7 | +# modify it under the terms of the GNU General Public License version 3. |
| 8 | +# |
| 9 | +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
| 10 | +# Copyright (C) 2006-2013 Jean-Philippe Lang |
| 11 | +# Copyright (C) 2010-2013 the ChiliProject Team |
| 12 | +# |
| 13 | +# This program is free software; you can redistribute it and/or |
| 14 | +# modify it under the terms of the GNU General Public License |
| 15 | +# as published by the Free Software Foundation; either version 2 |
| 16 | +# of the License, or (at your option) any later version. |
| 17 | +# |
| 18 | +# This program is distributed in the hope that it will be useful, |
| 19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | +# GNU General Public License for more details. |
| 22 | +# |
| 23 | +# You should have received a copy of the GNU General Public License |
| 24 | +# along with this program; if not, write to the Free Software |
| 25 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 26 | +# |
| 27 | +# See doc/COPYRIGHT.rdoc for more details. |
| 28 | +#++ |
| 29 | + |
| 30 | +# Compares the major version of the Hocuspocus client (@hocuspocus/provider, in |
| 31 | +# the frontend) against the server (@hocuspocus/server, in the op-blocknote-hocuspocus |
| 32 | +# extension). The client ships with the core app; the server ships as the separately |
| 33 | +# built and deployed openproject/hocuspocus image, and the two live in separate |
| 34 | +# dependabot ecosystems that can never be grouped — so they bump independently and |
| 35 | +# can silently drift. This flags a major mismatch for human review. It never fails |
| 36 | +# the build: Hocuspocus supports a one-major skew in both directions, so a mismatch |
| 37 | +# is a heads-up, not a blocker. |
| 38 | + |
| 39 | +set -e |
| 40 | + |
| 41 | +PROVIDER_RANGE=$(jq -r '.dependencies["@hocuspocus/provider"] // empty' frontend/package.json) |
| 42 | +SERVER_RANGE=$(jq -r '.dependencies["@hocuspocus/server"] // empty' extensions/op-blocknote-hocuspocus/package.json) |
| 43 | + |
| 44 | +if [ -z "$PROVIDER_RANGE" ] || [ -z "$SERVER_RANGE" ]; then |
| 45 | + echo "::warning::Could not read @hocuspocus/provider or @hocuspocus/server version; skipping skew check." |
| 46 | + exit 0 |
| 47 | +fi |
| 48 | + |
| 49 | +# Strip a leading range operator (^, ~, >=, etc.) and take the major version. |
| 50 | +major() { |
| 51 | + echo "$1" | sed -E 's/^[^0-9]*//' | cut -d. -f1 |
| 52 | +} |
| 53 | + |
| 54 | +PROVIDER_MAJOR=$(major "$PROVIDER_RANGE") |
| 55 | +SERVER_MAJOR=$(major "$SERVER_RANGE") |
| 56 | + |
| 57 | +echo "@hocuspocus/provider (client): ${PROVIDER_RANGE} (major ${PROVIDER_MAJOR})" |
| 58 | +echo "@hocuspocus/server (server): ${SERVER_RANGE} (major ${SERVER_MAJOR})" |
| 59 | + |
| 60 | +{ |
| 61 | + echo "provider_range=${PROVIDER_RANGE}" |
| 62 | + echo "server_range=${SERVER_RANGE}" |
| 63 | + echo "provider_major=${PROVIDER_MAJOR}" |
| 64 | + echo "server_major=${SERVER_MAJOR}" |
| 65 | +} >> "${GITHUB_OUTPUT:-/dev/stdout}" |
| 66 | + |
| 67 | +if [ "$PROVIDER_MAJOR" != "$SERVER_MAJOR" ]; then |
| 68 | + echo "Major version skew detected between Hocuspocus client and server." |
| 69 | + echo "skew=true" >> "${GITHUB_OUTPUT:-/dev/stdout}" |
| 70 | +else |
| 71 | + echo "Hocuspocus client and server are on the same major version." |
| 72 | + echo "skew=false" >> "${GITHUB_OUTPUT:-/dev/stdout}" |
| 73 | +fi |
0 commit comments