From 0a1c2bf88213a135e8a5aea5d6fc92260bdefeef Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 4 Nov 2024 10:26:31 +0000 Subject: [PATCH 1/7] Follow Security Guide to update release.yml --- .github/workflows/release.yml | 111 +++++++++++++++++----------------- 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d11bd2566..de9f42c07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,13 +19,16 @@ env: repository_zip_name: ${{ github.event.repository.name }}-${{ github.event.inputs.version_number }}.zip # Source folder list for version number updates source_folder_list: "source test" + repository_name: ${{ github.event.repository.name }} + version_number: ${{ github.event.inputs.version_number }} + actor: ${{ github.actor }} + commit_id: ${{ github.event.inputs.commit_id }} jobs: clean-existing-tag-and-release: if: ${{ github.event.inputs.delete_existing_tag_release == 'true' }} runs-on: ubuntu-latest env: - VERSION_NUM: ${{ github.event.inputs.version_number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout code @@ -34,10 +37,10 @@ jobs: - name: Check if tag exists run: | git fetch origin - if git tag --list $VERSION_NUM + if git tag --list ${{ env.version_number }} then - echo "Deleting existing tag for $VERSION_NUM" - git push origin --delete tags/$VERSION_NUM + echo "Deleting existing tag for ${{ env.version_number }}" + git push origin --delete tags/${{ env.version_number }} fi - name: Check if release exists @@ -46,10 +49,10 @@ jobs: sudo apt-add-repository https://cli.github.com/packages sudo apt update sudo apt-get install gh - if gh release list | grep $VERSION_NUM + if gh release list | grep ${{ env.version_number }} then - echo "Deleting existing release for $VERSION_NUM" - gh release delete --yes $VERSION_NUM + echo "Deleting existing release for ${{ env.version_number }} + gh release delete --yes ${{ env.version_number }} fi add-sbom-and-tag-commit: @@ -61,47 +64,47 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.commit_id }} + ref: ${{ env.commit_id }} - name: Configure git identity run: | - git config --global user.name ${{ github.actor }} - git config --global user.email ${{ github.actor }}@users.noreply.github.com + git config --global user.name ${{ env.actor }} + git config --global user.email ${{ env.actor }}@users.noreply.github.com - name: create a new branch that references commit id - run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }} + run: git checkout -b ${{ env.version_number }} ${{ env.commit_id }} - name: Update version number in source files run: | echo "${{ env.source_folder_list }}" | \ xargs -n 1 sh -c \ 'find $1 -type f \( -name "*.c" -o -name "*.h" \) \ - -exec sed -i -b -E "0,/^ \* ${{ github.event.repository.name }}/s/^ \* ${{ github.event.repository.name }}.*/ \* ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }}/g" {} +' + -exec sed -i -b -E "0,/^ \* ${{ env.repository_name }}/s/^ \* ${{ env.repository_name }}.*/ \* ${{ env.repository_name }} ${{ env.version_number }}/g" {} +' git add . git commit -m '[AUTO][RELEASE]: Update version number in source files' - git push -u origin ${{ github.event.inputs.version_number }} + git push -u origin ${{ env.version_number }} - name : Update version number in manifest.yml run: | - sed -i -b '0,/^version/s/^version.*/version: "${{ github.event.inputs.version_number }}"/g' ./manifest.yml + sed -i -b '0,/^version/s/^version.*/version: "${{ env.version_number }}"/g' ./manifest.yml git add . git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml' - git push -u origin ${{ github.event.inputs.version_number }} + git push -u origin ${{ env.version_number }} - name : Update version number in doxygen run: | - sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = ${{ github.event.inputs.version_number }}/g' ./docs/doxygen/config.doxyfile + sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = ${{ env.version_number }}/g' ./docs/doxygen/config.doxyfile git add . git commit -m '[AUTO][RELEASE]: Update version number in doxygen' - git push -u origin ${{ github.event.inputs.version_number }} + git push -u origin ${{ env.version_number }} - name : Update MQTT version number macro - if: ${{ github.event.repository.name == 'coreMQTT' }} + if: ${{ env.repository_name == 'coreMQTT' }} run: | - sed -i -b 's/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "${{ github.event.inputs.version_number }}"/g' source/include/core_mqtt.h + sed -i -b 's/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "${{ env.version_number }}"/g' source/include/core_mqtt.h git add . git commit -m '[AUTO][RELEASE]: Update version number macro in source/include/core_mqtt.h' - git push -u origin ${{ github.event.inputs.version_number }} + git push -u origin ${{ env.version_number }} - name: Generate SBOM uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main @@ -113,19 +116,19 @@ jobs: run: | git add . git commit -m 'Update SBOM' - git push -u origin ${{ github.event.inputs.version_number }} + git push -u origin ${{ env.version_number }} - name: Tag Commit and Push to remote run: | - git tag ${{ github.event.inputs.version_number }} -a -m "${{ github.event.repository.name }} Library ${{ github.event.inputs.version_number }}" + git tag ${{ env.version_number }} -a -m "${{ env.repository_name }} Library ${{ env.version_number }}" git push origin --tags - name: Verify tag on remote run: | - git tag -d ${{ github.event.inputs.version_number }} + git tag -d ${{ env.version_number }} git remote update - git checkout tags/${{ github.event.inputs.version_number }} - git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }} + git checkout tags/${{ env.version_number }} + git diff ${{ env.commit_id }} tags/${{ env.version_number }} create-zip: if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }} @@ -139,18 +142,18 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.version_number }} - path: ${{ github.event.repository.name }} + ref: ${{ env.version_number }} + path: ${{ env.repository_name }} submodules: recursive - name: Checkout disabled submodules run: | - cd ${{ github.event.repository.name }} + cd ${{ env.repository_name }} git submodule update --init --checkout --recursive - name: Create ZIP run: | - zip -r ${{ env.repository_zip_name }} ${{ github.event.repository.name }} -x "*.git*" + zip -r ${{ env.repository_zip_name }} ${{ env.repository_name }} -x "*.git*" ls ./ - name: Validate created ZIP @@ -160,66 +163,66 @@ jobs: cd zip-check unzip ${{ env.repository_zip_name }} -d ${{ env.repository_compressed_name }} ls ${{ env.repository_compressed_name }} - diff -r -x "*.git*" ${{ env.repository_compressed_name }}/${{ github.event.repository.name }}/ ../${{ github.event.repository.name }}/ + diff -r -x "*.git*" ${{ env.repository_compressed_name }}/${{ env.repository_name }}/ ../${{ env.repository_name }}/ cd ../ - name: Check version number in source files run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }} + cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} # List all the *.h *.c files in SOURCE_FILE_LIST=$( echo "${{ env.source_folder_list }}" | \ xargs -n 1 sh -c 'find $1 -type f \( -name "*.c" -o -name "*.h" \)' ) # List all the files which contain " * .*" in SOURCE_FILE_LIST - SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* ${{ github.event.repository.name }}.*" $SOURCE_FILE_LIST ) + SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* ${{ env.repository_name }}.*" $SOURCE_FILE_LIST ) # Compare the with input version number in files in SOURCE_FILE_LIST echo $SOURCE_FILE_WITH_VERSION_LIST | xargs -I{} sh -c \ - 'grep -x " \* ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }}" {} && \ - echo {} : match ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} || \ - { echo "{} : ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} not found"; exit 255; }' + 'grep -x " \* ${{ env.repository_name }} ${{ env.version_number }}" {} && \ + echo {} : match ${{ env.repository_name }} ${{ env.version_number }} || \ + { echo "{} : ${{ env.repository_name }} ${{ env.version_number }} not found"; exit 255; }' - name: Check version number in doxygen run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }} + cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} # find "PROJECT_NUMBER = " DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); # compare the with input version number - [[ $DOXYGEN_VERSION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \ - && echo "config.doxyfile : match ${{ github.event.inputs.version_number }}" \ - || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; } + [[ $DOXYGEN_VERSION_NUMBER == "${{ env.version_number }}" ]] \ + && echo "config.doxyfile : match ${{ env.version_number }}" \ + || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match ${{ env.version_number }}"; exit 255; } - name: Check version number in manifest.yml run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }} + cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} # find the first occurence of "version: " and comare the with input version number MANIFEST_VESION_NUMBER=$( grep -m 1 -E "^version:[ ]*\".*\"[ ]*" manifest.yml | awk -F: '{ gsub(" ","",$2); gsub("\"","",$2); print $2 }' ); # compare the with input version number - [[ $MANIFEST_VESION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \ - && echo "manifest.yml : match ${{ github.event.inputs.version_number }}" \ - || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; } + [[ $MANIFEST_VESION_NUMBER == "${{ env.version_number }}" ]] \ + && echo "manifest.yml : match ${{ env.version_number }}" \ + || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match ${{ env.version_number }}"; exit 255; } - name: Check MQTT version number macro in header file - if: ${{ github.event.repository.name == 'coreMQTT' }} + if: ${{ env.repository_name == 'coreMQTT' }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }} + cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} # find "#define MQTT_LIBRARY_VERSION " in core_mqtt.h MACRO_VERSION_NUMBER=$(grep -x "^\#define[ ]*MQTT_LIBRARY_VERSION[ ]*\".*\"[ ]*" source/include/core_mqtt.h | awk '{gsub("\"","",$3); print $3 }'); # compare the with input version number - [[ $MACRO_VERSION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \ - && echo "core_mqtt.h : match ${{ github.event.inputs.version_number }}" \ - || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; } + [[ $MACRO_VERSION_NUMBER == "${{ env.version_number }}" ]] \ + && echo "core_mqtt.h : match ${{ env.version_number }}" \ + || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match ${{ env.version_number }}"; exit 255; } - name: Build run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }} + cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} sudo apt-get install -y lcov cmake -S test -B build/ \ -G "Unix Makefiles" \ @@ -230,7 +233,7 @@ jobs: - name: Test run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}/build/ + cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }}/build/ ctest -E system --output-on-failure cd .. @@ -249,7 +252,7 @@ jobs: - name: Doxygen generation uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main with: - ref: ${{ github.event.inputs.version_number }} + ref: ${{ env.version_number }} add_release: "true" create-release: @@ -266,9 +269,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.event.inputs.version_number }} - release_name: ${{ github.event.inputs.version_number }} - body: Release ${{ github.event.inputs.version_number }} of the ${{ github.event.repository.name }} Library. + tag_name: ${{ env.version_number }} + release_name: ${{ env.version_number }} + body: Release ${{ env.version_number }} of the ${{ env.repository_name }} Library. draft: false prerelease: false From 5563bca283a2f381667d640ba5b38b545acc2784 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 4 Nov 2024 10:32:57 +0000 Subject: [PATCH 2/7] Fix Coverity link --- tools/coverity/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/coverity/README.md b/tools/coverity/README.md index da598f2a0..58d5d27a7 100644 --- a/tools/coverity/README.md +++ b/tools/coverity/README.md @@ -12,7 +12,7 @@ see the [MISRA.md](https://github.com/FreeRTOS/coreMQTT/blob/main/MISRA.md) file ## Getting Started ### Prerequisites -You can run this on a platform supported by Coverity. The list and other details can be found [here](https://sig-docs.synopsys.com/polaris/topics/c_coverity-compatible-platforms.html). +You can run this on a platform supported by Coverity. The list and other details can be found [here](https://documentation.blackduck.com/bundle/coverity-docs/page/deploy-install-guide/topics/supported_platforms_for_coverity_analysis.html). To compile and run the Coverity target successfully, you must have the following: 1. CMake version > 3.13.0 (You can check whether you have this by typing `cmake --version`) From 5ee17e87981775f35e13f7fefe656284c354b3f9 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 4 Nov 2024 10:55:13 +0000 Subject: [PATCH 3/7] Update release.yml again. --- .github/workflows/release.yml | 157 ++++++++++++++++++++++------------ docs/doxygen/config.doxyfile | 2 +- 2 files changed, 101 insertions(+), 58 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de9f42c07..c89beeb9e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,16 +19,13 @@ env: repository_zip_name: ${{ github.event.repository.name }}-${{ github.event.inputs.version_number }}.zip # Source folder list for version number updates source_folder_list: "source test" - repository_name: ${{ github.event.repository.name }} - version_number: ${{ github.event.inputs.version_number }} - actor: ${{ github.actor }} - commit_id: ${{ github.event.inputs.commit_id }} jobs: clean-existing-tag-and-release: if: ${{ github.event.inputs.delete_existing_tag_release == 'true' }} runs-on: ubuntu-latest env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout code @@ -37,10 +34,10 @@ jobs: - name: Check if tag exists run: | git fetch origin - if git tag --list ${{ env.version_number }} + if git tag --list $VERSION_NUMBER then - echo "Deleting existing tag for ${{ env.version_number }}" - git push origin --delete tags/${{ env.version_number }} + echo "Deleting existing tag for $VERSION_NUMBER" + git push origin --delete tags/$VERSION_NUMBER fi - name: Check if release exists @@ -49,10 +46,10 @@ jobs: sudo apt-add-repository https://cli.github.com/packages sudo apt update sudo apt-get install gh - if gh release list | grep ${{ env.version_number }} + if gh release list | grep $VERSION_NUMBER then - echo "Deleting existing release for ${{ env.version_number }} - gh release delete --yes ${{ env.version_number }} + echo "Deleting existing release for $VERSION_NUMBER" + gh release delete --yes $VERSION_NUMBER fi add-sbom-and-tag-commit: @@ -64,47 +61,61 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ env.commit_id }} + ref: ${{ github.event.inputs.commit_id }} - name: Configure git identity + env: + ACTOR: ${{ github.actor }} run: | - git config --global user.name ${{ env.actor }} - git config --global user.email ${{ env.actor }}@users.noreply.github.com + git config --global user.name "$ACTOR" + git config --global user.email "$ACTOR"@users.noreply.github.com - name: create a new branch that references commit id - run: git checkout -b ${{ env.version_number }} ${{ env.commit_id }} + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + COMMIT_ID: ${{ github.event.inputs.commit_id }} + run: git checkout -b "$VERSION_NUMBER" "$COMMIT_ID" - name: Update version number in source files + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + REPO_NAME: ${{ github.event.repository.name }} run: | echo "${{ env.source_folder_list }}" | \ xargs -n 1 sh -c \ 'find $1 -type f \( -name "*.c" -o -name "*.h" \) \ - -exec sed -i -b -E "0,/^ \* ${{ env.repository_name }}/s/^ \* ${{ env.repository_name }}.*/ \* ${{ env.repository_name }} ${{ env.version_number }}/g" {} +' + -exec sed -i -b -E "0,/^ \* $REPO_NAME/s/^ \* $REPO_NAME.*/ \* $REPO_NAME $VERSION_NUMBER/g" {} +' git add . git commit -m '[AUTO][RELEASE]: Update version number in source files' - git push -u origin ${{ env.version_number }} + git push -u origin "$VERSION_NUMBER" - name : Update version number in manifest.yml + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - sed -i -b '0,/^version/s/^version.*/version: "${{ env.version_number }}"/g' ./manifest.yml + sed -i -b '0,/^version/s/^version.*/version: "$VERSION_NUMBER"/g' ./manifest.yml git add . git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml' - git push -u origin ${{ env.version_number }} + git push -u origin "$VERSION_NUMBER" - name : Update version number in doxygen + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = ${{ env.version_number }}/g' ./docs/doxygen/config.doxyfile + sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $VERSION_NUMBER/g' ./docs/doxygen/config.doxyfile git add . git commit -m '[AUTO][RELEASE]: Update version number in doxygen' - git push -u origin ${{ env.version_number }} + git push -u origin "$VERSION_NUMBER" - name : Update MQTT version number macro - if: ${{ env.repository_name == 'coreMQTT' }} + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + if: ${{ github.event.repository.name == 'coreMQTT' }} run: | - sed -i -b 's/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "${{ env.version_number }}"/g' source/include/core_mqtt.h + sed -i -b 's/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "$VERSION_NUMBER"/g' source/include/core_mqtt.h git add . git commit -m '[AUTO][RELEASE]: Update version number macro in source/include/core_mqtt.h' - git push -u origin ${{ env.version_number }} + git push -u origin "$VERSION_NUMBER" - name: Generate SBOM uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main @@ -113,22 +124,30 @@ jobs: source_path: ./source - name: commit SBOM file + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | git add . git commit -m 'Update SBOM' - git push -u origin ${{ env.version_number }} + git push -u origin "$VERSION_NUMBER" - name: Tag Commit and Push to remote + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + REPO_NAME: ${{ github.event.repository.name }} run: | - git tag ${{ env.version_number }} -a -m "${{ env.repository_name }} Library ${{ env.version_number }}" + git tag "$VERSION_NUMBER" -a -m "$REPO_NAME Library $VERSION_NUMBER" git push origin --tags - name: Verify tag on remote + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + COMMIT_ID: ${{ github.event.inputs.commit_id }} run: | - git tag -d ${{ env.version_number }} + git tag -d "$VERSION_NUMBER" git remote update - git checkout tags/${{ env.version_number }} - git diff ${{ env.commit_id }} tags/${{ env.version_number }} + git checkout tags/"$VERSION_NUMBER" + git diff "$COMMIT_ID" tags/"$VERSION_NUMBER" create-zip: if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }} @@ -142,87 +161,108 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ env.version_number }} - path: ${{ env.repository_name }} + ref: ${{ github.event.inputs.version_number }} + path: ${{ github.event.repository.name }} submodules: recursive - name: Checkout disabled submodules + env: + REPO_NAME: ${{ github.event.repository.name }} run: | - cd ${{ env.repository_name }} + cd "$REPO_NAME" git submodule update --init --checkout --recursive - name: Create ZIP + env: + REPO_NAME: ${{ github.event.repository.name }} run: | - zip -r ${{ env.repository_zip_name }} ${{ env.repository_name }} -x "*.git*" + zip -r ${{ env.repository_zip_name }} "$REPO_NAME" -x "*.git*" ls ./ - name: Validate created ZIP + env: + REPO_NAME: ${{ github.event.repository.name }} run: | mkdir zip-check mv ${{ env.repository_zip_name }} zip-check cd zip-check unzip ${{ env.repository_zip_name }} -d ${{ env.repository_compressed_name }} ls ${{ env.repository_compressed_name }} - diff -r -x "*.git*" ${{ env.repository_compressed_name }}/${{ env.repository_name }}/ ../${{ env.repository_name }}/ + diff -r -x "*.git*" ${{ env.repository_compressed_name }}/"$REPO_NAME"/ ../"$REPO_NAME"/ cd ../ - name: Check version number in source files + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + REPO_NAME: ${{ github.event.repository.name }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} + cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # List all the *.h *.c files in SOURCE_FILE_LIST=$( echo "${{ env.source_folder_list }}" | \ xargs -n 1 sh -c 'find $1 -type f \( -name "*.c" -o -name "*.h" \)' ) # List all the files which contain " * .*" in SOURCE_FILE_LIST - SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* ${{ env.repository_name }}.*" $SOURCE_FILE_LIST ) + SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* $REPO_NAME.*" $SOURCE_FILE_LIST ) # Compare the with input version number in files in SOURCE_FILE_LIST echo $SOURCE_FILE_WITH_VERSION_LIST | xargs -I{} sh -c \ - 'grep -x " \* ${{ env.repository_name }} ${{ env.version_number }}" {} && \ - echo {} : match ${{ env.repository_name }} ${{ env.version_number }} || \ - { echo "{} : ${{ env.repository_name }} ${{ env.version_number }} not found"; exit 255; }' + 'grep -x " \* $REPO_NAME $VERSION_NUMBER" {} && \ + echo {} : match "$REPO_NAME" "$VERSION_NUMBER" || \ + { echo "{} : $REPO_NAME $VERSION_NUMBER not found"; exit 255; }' - name: Check version number in doxygen + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + REPO_NAME: ${{ github.event.repository.name }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} + cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find "PROJECT_NUMBER = " DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); # compare the with input version number - [[ $DOXYGEN_VERSION_NUMBER == "${{ env.version_number }}" ]] \ - && echo "config.doxyfile : match ${{ env.version_number }}" \ - || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match ${{ env.version_number }}"; exit 255; } + echo "Comparing $DOXYGEN_VERSION_NUMBER & $VERSION_NUMBER" + [[ $DOXYGEN_VERSION_NUMBER == $VERSION_NUMBER ]] \ + && echo "config.doxyfile : match $VERSION_NUMBER" \ + || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; } - name: Check version number in manifest.yml + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + REPO_NAME: ${{ github.event.repository.name }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} + cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find the first occurence of "version: " and comare the with input version number MANIFEST_VESION_NUMBER=$( grep -m 1 -E "^version:[ ]*\".*\"[ ]*" manifest.yml | awk -F: '{ gsub(" ","",$2); gsub("\"","",$2); print $2 }' ); # compare the with input version number - [[ $MANIFEST_VESION_NUMBER == "${{ env.version_number }}" ]] \ - && echo "manifest.yml : match ${{ env.version_number }}" \ - || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match ${{ env.version_number }}"; exit 255; } + [[ $MANIFEST_VESION_NUMBER == "$VERSION_NUMBER" ]] \ + && echo "manifest.yml : match $VERSION_NUMBER" \ + || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; } - name: Check MQTT version number macro in header file - if: ${{ env.repository_name == 'coreMQTT' }} + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + REPO_NAME: ${{ github.event.repository.name }} + if: ${{ github.event.repository.name == 'coreMQTT' }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} + cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find "#define MQTT_LIBRARY_VERSION " in core_mqtt.h MACRO_VERSION_NUMBER=$(grep -x "^\#define[ ]*MQTT_LIBRARY_VERSION[ ]*\".*\"[ ]*" source/include/core_mqtt.h | awk '{gsub("\"","",$3); print $3 }'); # compare the with input version number - [[ $MACRO_VERSION_NUMBER == "${{ env.version_number }}" ]] \ - && echo "core_mqtt.h : match ${{ env.version_number }}" \ - || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match ${{ env.version_number }}"; exit 255; } + [[ $MACRO_VERSION_NUMBER == "$VERSION_NUMBER" ]] \ + && echo "core_mqtt.h : match $VERSION_NUMBER" \ + || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; } - name: Build + env: + REPO_NAME: ${{ github.event.repository.name }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }} + cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" sudo apt-get install -y lcov cmake -S test -B build/ \ -G "Unix Makefiles" \ @@ -232,8 +272,10 @@ jobs: make -C build/ all - name: Test + env: + REPO_NAME: ${{ github.event.repository.name }} run: | - cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }}/build/ + cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME"/build/ ctest -E system --output-on-failure cd .. @@ -252,7 +294,7 @@ jobs: - name: Doxygen generation uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main with: - ref: ${{ env.version_number }} + ref: ${{ github.event.inputs.version_number }} add_release: "true" create-release: @@ -269,9 +311,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ env.version_number }} - release_name: ${{ env.version_number }} - body: Release ${{ env.version_number }} of the ${{ env.repository_name }} Library. + tag_name: ${{ github.event.inputs.version_number }} + release_name: ${{ github.event.inputs.version_number }} + body: Release ${{ github.event.inputs.version_number }} of the ${{ github.event.repository.name }} Library. draft: false prerelease: false @@ -290,3 +332,4 @@ jobs: asset_path: ./${{ env.repository_zip_name }} asset_name: ${{ env.repository_zip_name }} asset_content_type: application/zip + \ No newline at end of file diff --git a/docs/doxygen/config.doxyfile b/docs/doxygen/config.doxyfile index ca0047ec4..6e154ad77 100644 --- a/docs/doxygen/config.doxyfile +++ b/docs/doxygen/config.doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = coreMQTT # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v2.3.1+ +PROJECT_NUMBER = v3.1.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From e8d920849e3dfb99eddc17e041844c094c0ea3b8 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 4 Nov 2024 16:22:52 +0000 Subject: [PATCH 4/7] Export DOXYGEN_VERSION_NUMBER --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c89beeb9e..5aad5dfbe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -219,7 +219,7 @@ jobs: cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find "PROJECT_NUMBER = " - DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); + export DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); # compare the with input version number echo "Comparing $DOXYGEN_VERSION_NUMBER & $VERSION_NUMBER" From 91806a9cf71724e879e99ca03325eaba27235c12 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 4 Nov 2024 16:27:00 +0000 Subject: [PATCH 5/7] Add quote in DOXYGEN_VERSION_NUMBER and revert config.doxyfile change --- .github/workflows/release.yml | 4 ++-- docs/doxygen/config.doxyfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5aad5dfbe..a057ff1b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -219,11 +219,11 @@ jobs: cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find "PROJECT_NUMBER = " - export DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); + DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); # compare the with input version number echo "Comparing $DOXYGEN_VERSION_NUMBER & $VERSION_NUMBER" - [[ $DOXYGEN_VERSION_NUMBER == $VERSION_NUMBER ]] \ + [[ '$DOXYGEN_VERSION_NUMBER' == $VERSION_NUMBER ]] \ && echo "config.doxyfile : match $VERSION_NUMBER" \ || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; } diff --git a/docs/doxygen/config.doxyfile b/docs/doxygen/config.doxyfile index 6e154ad77..ca0047ec4 100644 --- a/docs/doxygen/config.doxyfile +++ b/docs/doxygen/config.doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = coreMQTT # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v3.1.1 +PROJECT_NUMBER = v2.3.1+ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From a3b36211352d397044887639d56ef5d4e10d80ae Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Tue, 5 Nov 2024 02:51:04 +0000 Subject: [PATCH 6/7] Rename DOXYGEN_VERSION_NUMBER to DOXYGEN_VERSION. --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a057ff1b3..5de4ad1d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -219,13 +219,13 @@ jobs: cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find "PROJECT_NUMBER = " - DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); + DOXYGEN_VERSION=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); # compare the with input version number - echo "Comparing $DOXYGEN_VERSION_NUMBER & $VERSION_NUMBER" - [[ '$DOXYGEN_VERSION_NUMBER' == $VERSION_NUMBER ]] \ + echo "Comparing $DOXYGEN_VERSION & $VERSION_NUMBER" + [[ $DOXYGEN_VERSION == $VERSION_NUMBER ]] \ && echo "config.doxyfile : match $VERSION_NUMBER" \ - || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; } + || { echo "config.doxyfile : $DOXYGEN_VERSION doesn't match $VERSION_NUMBER"; exit 255; } - name: Check version number in manifest.yml env: From 83f0d8883557c13b64e037766eedda8ded681197 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Tue, 5 Nov 2024 03:03:20 +0000 Subject: [PATCH 7/7] Fix quote issue. --- .github/workflows/release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5de4ad1d4..727309142 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: env: VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - sed -i -b '0,/^version/s/^version.*/version: "$VERSION_NUMBER"/g' ./manifest.yml + sed -i -b "0,/^version/s/^version.*/version: \"$VERSION_NUMBER\"/g" ./manifest.yml git add . git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml' git push -u origin "$VERSION_NUMBER" @@ -102,7 +102,7 @@ jobs: env: VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $VERSION_NUMBER/g' ./docs/doxygen/config.doxyfile + sed -i -b "s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $VERSION_NUMBER/g" ./docs/doxygen/config.doxyfile git add . git commit -m '[AUTO][RELEASE]: Update version number in doxygen' git push -u origin "$VERSION_NUMBER" @@ -112,7 +112,7 @@ jobs: VERSION_NUMBER: ${{ github.event.inputs.version_number }} if: ${{ github.event.repository.name == 'coreMQTT' }} run: | - sed -i -b 's/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "$VERSION_NUMBER"/g' source/include/core_mqtt.h + sed -i -b "s/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION \"$VERSION_NUMBER\"/g" source/include/core_mqtt.h git add . git commit -m '[AUTO][RELEASE]: Update version number macro in source/include/core_mqtt.h' git push -u origin "$VERSION_NUMBER" @@ -219,13 +219,13 @@ jobs: cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" # find "PROJECT_NUMBER = " - DOXYGEN_VERSION=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); + DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }'); # compare the with input version number - echo "Comparing $DOXYGEN_VERSION & $VERSION_NUMBER" - [[ $DOXYGEN_VERSION == $VERSION_NUMBER ]] \ + echo "Comparing $DOXYGEN_VERSION_NUMBER & $VERSION_NUMBER" + [[ $DOXYGEN_VERSION_NUMBER == $VERSION_NUMBER ]] \ && echo "config.doxyfile : match $VERSION_NUMBER" \ - || { echo "config.doxyfile : $DOXYGEN_VERSION doesn't match $VERSION_NUMBER"; exit 255; } + || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; } - name: Check version number in manifest.yml env: @@ -238,7 +238,7 @@ jobs: MANIFEST_VESION_NUMBER=$( grep -m 1 -E "^version:[ ]*\".*\"[ ]*" manifest.yml | awk -F: '{ gsub(" ","",$2); gsub("\"","",$2); print $2 }' ); # compare the with input version number - [[ $MANIFEST_VESION_NUMBER == "$VERSION_NUMBER" ]] \ + [[ $MANIFEST_VESION_NUMBER == $VERSION_NUMBER ]] \ && echo "manifest.yml : match $VERSION_NUMBER" \ || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; }