From 98b6be28d4ccb3fd77d23443731edd7687c9fdad Mon Sep 17 00:00:00 2001 From: autoupdate Date: Wed, 26 Jul 2023 20:00:52 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=20(autoupdate)=20Move=20auto=20up?= =?UTF-8?q?date=20git=20code=20to=20autoupdate.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoupdate.sh | 15 ++++++++++++++- update-new-version.sh | 27 ++------------------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/autoupdate.sh b/autoupdate.sh index f4a068b..1386bb7 100755 --- a/autoupdate.sh +++ b/autoupdate.sh @@ -5,7 +5,10 @@ set -euo pipefail dir="$(find . -maxdepth 1 -type d -name "intellij-idea-*")" pushd "$dir" || exit 1 +set +e check="$(uscan --dehs --no-download)" +set -e + status="$(echo "$check" | xmllint --xpath 'string(/dehs/status)' -)" if [[ "$status" != "newer package available" ]]; then @@ -17,4 +20,14 @@ new_version="$(echo "$check" | xmllint --xpath 'string(/dehs/upstream-version)' popd -./update-new-version.sh --autoupdate "$new_version" +./update-new-version.sh "$new_version" + +git add -A +git commit -m "Upstream version $new_version" + +git switch main +git merge --ff-only version-"$new_version" +git push origin main + +git tag -a v"$new_version" -m "Upstream version $new_version" +git push --tags origin main diff --git a/update-new-version.sh b/update-new-version.sh index ae416a3..ec7c5aa 100755 --- a/update-new-version.sh +++ b/update-new-version.sh @@ -1,8 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash # # This script intends to decrease the effort of updating the package. -# -# Passing "--autoupdate" as first argument triggers automatic Git operations. set -euo pipefail @@ -18,14 +16,7 @@ DISTRIBUTION="lunar" last_tag=$(git describe --abbrev=0 --tags) old="${last_tag#?}" - -if [ "$1" = "--autoupdate" ]; then - new="$2" - autoupdate="y" -else - new="$1" - autoupdate="n" -fi +new="$1" name="$(git config --get user.name)" email="$(git config --get user.email)" @@ -51,17 +42,3 @@ debuild -us -uc cd .. rm "$PACKAGE"_"$old"-* - -if [ "$autoupdate" = "n" ]; then - exit -fi - -git add -A -git commit -m "Upstream version $new" - -git switch main -git merge --ff-only version-"$new" -git push origin main - -git tag -a v"$new" -m "Upstream version $new" -git push --tags origin main From 0a1ee6c30eae2f3db8e0ecdaf45660e41efe4572 Mon Sep 17 00:00:00 2001 From: autoupdate Date: Wed, 26 Jul 2023 20:01:17 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=B7=20(autoupdate)=20Add=20auto=20?= =?UTF-8?q?update=20job?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da9fec4..8305eb9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,9 +9,43 @@ variables: EMAIL: "opensource@mmk2410.org" stages: + - autoupdate - build - deploy +update-job: + stage: autoupdate + script: + ## + ## Install necessary packages. + ## + - apt update && apt install -y git devscripts debhelper libxml2-utils openssh-client + + ## + ## Configure SSH key + ## + - eval $(ssh-agent -s) + - chmod 400 "$SSH_PRIVATE_KEY" + - ssh-add "$SSH_PRIVATE_KEY" + - mkdir ~/.ssh + - chmod 700 ~/.ssh + - cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + + ## + ## Configure Git setup + ## + - git config user.name "$NAME" + - git config user.email "$EMAIL" + - git remote set-url origin "$GIT_URL" + + ## + ## Run autoupdate script which handles everything else. + ## + - ./autoupdate.sh + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + build-job: stage: build script: