From 411e56ab86f1215d4f939b903a57e383b7301142 Mon Sep 17 00:00:00 2001 From: constanca Date: Tue, 24 Sep 2024 10:09:36 +0200 Subject: [PATCH] Update version workflow. Signed-off-by: constanca --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/workflows/changelog.yml | 37 ------------------------- .github/workflows/version-update.yml | 41 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/version-update.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2b7c1c05..205800d9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -33,7 +33,7 @@ List here all the items you have verified BEFORE sending this PR. Please DO NOT - [ ] I have made corresponding changes to the documentation - [ ] I have made corresponding change to the default configuration files - [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] I have added an entry in `CHANGELOG.md` +- [ ] I have added an entry in `CHANGELOG.md` and updated `share/version.py`, if my change requires a new release. ## Author's Checklist diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml deleted file mode 100644 index 527cb043..00000000 --- a/.github/workflows/changelog.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -## Workflow to check CHANGELOG was updated when version gets updated in share/version.py -name: changelog - -on: - pull_request: - paths: - - 'share/version.py' - -jobs: - - changelog: - runs-on: ubuntu-latest - timeout-minutes: 5 - - steps: - - - uses: actions/checkout@v4 - - - name: Get version number - shell: bash - run: | - VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' share/version.py) - echo "VERSION=${VERSION}" >> $GITHUB_ENV - echo "::notice::ESF version is $VERSION." - - - name: Check changelog - shell: bash - run: | - first_line=$(awk 'NR==1' CHANGELOG.md) - - if [[ $first_line != *" v${{ env.VERSION }} "* ]]; then - error="CHANGELOG should contain the new version in its first line, like this ' v1.1.1 '." - reminder="Do not forget to add space before and after the version in the CHANGELOG first line." - echo "::error::$error $reminder" - exit 1 - fi diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml new file mode 100644 index 00000000..ad657eb5 --- /dev/null +++ b/.github/workflows/version-update.yml @@ -0,0 +1,41 @@ +--- +# Workflow to check that the version inside share/version.py matches the version in the last entry +# of CHANGELOG +name: version-update + +on: + pull_request: + paths: + - 'share/version.py' + - 'CHANGELOG.md' + +jobs: + + version-increase: + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + + - uses: actions/checkout@v4 + + - name: Compare versions in share/version.py and CHANGELOG last entry + shell: bash + run: | + # Get the version inside share/version.py + version_py=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' share/version.py) + echo "::notice::Version inside share/version.py is $version_py." + + # Assumes the first line of the CHANGELOG file follows a format like this: '### v1.17.1 - 2024/09/23' + # Example: + # Input: '### v1.17.1 - 2024/09/23' + # Output: '1.17.1' + version_changelog=$(awk 'NR==1' CHANGELOG.md | awk '{print substr($2,2)}') + echo "::notice::Version in CHANGELOG last entry is $version_changelog." + + if [ "$version_changelog" != "$version_py" ]; then + error="Versions in share/version.py and CHANGELOG do not match." + reminder="Make sure CHANGELOG first line follows format '### v - '." + echo "::error::$error $reminder" + exit 1 + fi