From 289e75a00c703aaa2a509082ba8a88515a0cd997c9503e5b2a0453b52b638250 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Wed, 31 Jul 2024 13:20:43 +0000 Subject: [PATCH] OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:cockpit/cockpit-machines?expand=0&rev=41 --- cockpit-machines.spec | 2 -- update_version.sh | 58 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 update_version.sh diff --git a/cockpit-machines.spec b/cockpit-machines.spec index 11cd1b3..33d09fe 100644 --- a/cockpit-machines.spec +++ b/cockpit-machines.spec @@ -22,8 +22,6 @@ Release: 0 Summary: Cockpit user interface for virtual machines License: LGPL-2.1-or-later AND MIT URL: https://github.com/cockpit-project/cockpit-machines -# source_validator insists that if obscpio has no version then -# tarball must neither Source: https://github.com/cockpit-project/cockpit-machines/archive/refs/tags/%{version}.tar.gz#/cockpit-machines-%{version}.tar.gz Source10: package-lock.json Source11: node_modules.spec.inc diff --git a/update_version.sh b/update_version.sh new file mode 100644 index 0000000..cf18d16 --- /dev/null +++ b/update_version.sh @@ -0,0 +1,58 @@ +#!/usr/bin/bash + +set -e + +curVersion=$(grep Version: cockpit-machines.spec | sed -e 's,^\(\s*Version:\s*\)\(.*\)\s*$,\2,') + +if [[ ! "$curVersion" =~ ^[0-9]+$ ]]; then + echo "Error: curVersion is not a valid integer" + exit 1 +fi + +### +### Fetch latest soruces +### + +GWD="-C cockpit-machines" + +# fetch latest cockpit-machines +if [ ! -d cockpit-machines ]; then + git clone https://github.com/cockpit-project/cockpit-machines cockpit-machines +else + git $GWD checkout main + git $GWD fetch +fi + +newVersion=$(git $GWD tag | grep '^[0-9.]\+$' | sort -rn | head -1) + +echo "Current version: $curVersion" +echo " New version: $newVersion" + +if [[ ! "$newVersion" =~ ^[0-9]+$ ]]; then + echo "Error: newVersion cannot be determined" + exit 1 +fi + +if [ "$curVersion" -ge "$newVersion" ]; then + echo "Nothing to do." + exit 0 +fi + +### +### UPDATE +### +# # initialize all submodules +git $GWD checkout --quiet $newVersion +git $GWD submodule update --init --depth 1 +diff cockpit-machines/node_modules/.package.json cockpit-machines/package.json +cp cockpit-machines/node_modules/.package-lock.json package-lock.json + +# update node_modules +curl -Lo cockpit-machines-$newVersion.tar.gz https://github.com/cockpit-project/cockpit-machines/archive/refs/tags/$newVersion.tar.gz + +# Updating version in spec file +sed -i -e "s,^\(\s*Version:\s*\)\(.*\)\s*$,\1${newVersion}," cockpit-machines.spec + +# update modules +osc service mr +