From 2de147665ac1a98e6e0d6928b34701f5890d66ba Mon Sep 17 00:00:00 2001 From: Ryan Brue Date: Sep 26 2024 22:12:45 +0000 Subject: scripts: add a 'NIGHTLY' argument to the scripts to make the inclusion of git commit hash and date optional this commit makes it possible for us to use the srpm and no-source-srpm script to make tagged releases also bump version to 1.0.0~alpha.2 (from 0.1.0) Signed-off-by: Ryan Brue --- diff --git a/scripts/no-source-srpm.sh b/scripts/no-source-srpm.sh index 4576fb1..9d7a064 100755 --- a/scripts/no-source-srpm.sh +++ b/scripts/no-source-srpm.sh @@ -15,9 +15,15 @@ check_variable() { } check_variable NAME -VERSION=${VERSION:-"0.1.0"} +VERSION=${VERSION:-"1.0.0~alpha.2"} +NIGHTLY=${NIGHTLY:-1} CURRENT_DATE=$(date +'%Y%m%d') # Make replacements to specfile -sed -i "/^Version: / s/.*/Version: ${VERSION}~^${CURRENT_DATE}gitnone/" $NAME.spec +if [ "$NIGHTLY" -eq 1 ] then + echo "NIGHTLY=1" + sed -i "/^Version: / s/.*/Version: ${VERSION}/" $NAME.spec +else + sed -i "/^Version: / s/.*/Version: ${VERSION}^${CURRENT_DATE}/" $NAME.spec +fi diff --git a/scripts/srpm.sh b/scripts/srpm.sh index df5de37..e670fa1 100755 --- a/scripts/srpm.sh +++ b/scripts/srpm.sh @@ -9,6 +9,7 @@ # COMMIT: latest or sha # REPO: link # VENDOR: 0 or 1 +# NIGHTLY: 0 or 1 check_variable() { local var_name=$1 @@ -20,10 +21,11 @@ check_variable() { check_variable NAME SOURCE_NAME=${SOURCE_NAME:-"$NAME"} -VERSION=${VERSION:-"0.1.0"} +VERSION=${VERSION:-"1.0.0~alpha.2"} COMMIT=${COMMIT:-"latest"} REPO=${REPO:-"https://github.com/pop-os/$SOURCE_NAME"} VENDOR=${VENDOR:-1} +NIGHTLY=${NIGHTLY:-1} if [ ! -e "$NAME" ]; then git clone --recurse-submodules $REPO $NAME @@ -40,6 +42,10 @@ SHORTCOMMIT=$(echo ${COMMIT:0:7}) git reset --hard $COMMIT +# Ensure commit is set to the current head of the local repo +# This is needed because if we reset to a tag, we want the commit to be in the commit field later on (for VERGEN) +COMMIT=$(git rev-parse HEAD) + COMMITDATE=$(git log -1 --format=%cd --date=format:%Y%m%d) COMMITDATESTRING=$(git log -1 --format=%cd --date=iso) @@ -64,7 +70,12 @@ fi cd .. # Make replacements to specfile -sed -i "/^Version: / s/.*/Version: $VERSION~^%{commitdate}git%{shortcommit}/" $NAME.spec +if [ "$NIGHTLY" -eq 1 ] then + echo "NIGHTLY=1" + sed -i "/^Version: / s/.*/Version: $VERSION^git%{commitdate}%{shortcommit}/" $NAME.spec +else + sed -i "/^Version: / s/.*/Version: $VERSION/" $NAME.spec +fi sed -i "/^%global commit / s/.*/%global commit $COMMIT/" $NAME.spec sed -i "/^%global commitdate / s/.*/%global commitdate $COMMITDATE/" $NAME.spec sed -i "/^%global commitdatestring / s/.*/%global commitdatestring $COMMITDATESTRING/" $NAME.spec