From a8a4f652114ae3f220d0965ed39ba9bec7cb46d7 Mon Sep 17 00:00:00 2001 From: cicdguy <26552821+cicdguy@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:10:55 -0600 Subject: [PATCH] Do not fail version check if development version is set (#197) Do not fail version check if development version is set --------- Signed-off-by: cicdguy <26552821+cicdguy@users.noreply.github.com> --- .github/workflows/version-bump.yaml | 13 +++---------- .github/workflows/version.yaml | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/version-bump.yaml b/.github/workflows/version-bump.yaml index 9e3a73e0..02c4798e 100644 --- a/.github/workflows/version-bump.yaml +++ b/.github/workflows/version-bump.yaml @@ -77,8 +77,8 @@ jobs: if [ -f NEWS.md ] then { git config --global --add safe.directory $(pwd) - DESC_VERSION=$(R --slave -e 'cat(paste(desc::desc_get_version()))') - NEWS_VERSION=$(awk '/^#+ /{print $3,$4; exit}' NEWS.md) + DESC_VERSION=$(R --slave -e 'cat(paste(desc::desc_get_version()))' | tr -d '\n') + NEWS_VERSION=$(awk '/^#+ /{print $3,$4; exit}' NEWS.md | tr -d '\n') FIRST_NEWS_LINE=$(head -1 NEWS.md) if [ "${{ inputs.vbump-after-release }}" == "true" ]; then # Add a new section with the released version that will be vbumped below. @@ -87,18 +87,11 @@ jobs: fi # Replace only the first occurence of $NEWS_VERSION, # but only if it's not already set to (development version) - if [ "$NEWS_VERSION" != "(development version)" ] + if [ "${NEWS_VERSION}" != "(development version)" ] then { sed -i "0,/$NEWS_VERSION/s/$NEWS_VERSION/$DESC_VERSION/" NEWS.md } fi - NEWS_VERSION=$(awk '/^#+ /{print $3,$4; exit}' NEWS.md) - echo "Updated NEWS.md version: $NEWS_VERSION" - if (test $DESC_VERSION != $NEWS_VERSION ); then - echo "🙈 Updated NEWS.md and DESCRIPTION have different versions!" - echo "Please ensure that the versions in the NEWS.md and DESCRIPTION are the same 🙏" - exit 1 - fi echo "NEW_PKG_VERSION=${DESC_VERSION}" >> $GITHUB_ENV } fi diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 1a18fb15..c8b3a429 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -39,17 +39,27 @@ jobs: - name: NEWS.md and DESCRIPTION Version check 🏁 run: | - DESC_VERSION=$(awk -F: '/Version:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION) - NEWS_VERSION=$(awk '/^#+ /{print $3; exit}' NEWS.md) + DESC_VERSION=$(awk -F: '/Version:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION | tr -d '\n') + NEWS_VERSION=$(awk '/^#+ /{print $3,$4; exit}' NEWS.md | tr -d '\n') + DESC_DEV_VERSION=$(echo $DESC_VERSION | awk -F '.' '{print $NF}') echo "NEWS.md version: $NEWS_VERSION" echo "DESCRIPTION version: $DESC_VERSION" - if (test $DESC_VERSION = $NEWS_VERSION ); then - echo "NEWS.md and DESCRIPTION have the same version" - else - echo "🙈 NEWS.md and DESCRIPTION have different versions!" - echo "🙏 Please fix this." - exit 1 + if test $DESC_VERSION = $NEWS_VERSION + then { + echo "NEWS.md and DESCRIPTION have the same version 🎉" + exit 0 + } fi + if [[ $DESC_DEV_VERSION -ge 9000 && "${NEWS_VERSION}" == "(development version)" ]] + then { + echo "NEWS.md and DESCRIPTION file versions are okay as package is in development mode." + echo "All is okay 🆗" + exit 0 + } + fi + echo "🙈 NEWS.md and DESCRIPTION have different versions!" + echo "🙏 Please fix this." + exit 1 shell: bash working-directory: ${{ inputs.package-subdirectory }}