2525 if : ${{ github.event.inputs.delete_existing_tag_release == 'true' }}
2626 runs-on : ubuntu-latest
2727 env :
28- VERSION_NUM : ${{ github.event.inputs.version_number }}
28+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
2929 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3030 steps :
3131 - name : Checkout code
@@ -34,10 +34,10 @@ jobs:
3434 - name : Check if tag exists
3535 run : |
3636 git fetch origin
37- if git tag --list $VERSION_NUM
37+ if git tag --list $VERSION_NUMBER
3838 then
39- echo "Deleting existing tag for $VERSION_NUM "
40- git push origin --delete tags/$VERSION_NUM
39+ echo "Deleting existing tag for $VERSION_NUMBER "
40+ git push origin --delete tags/$VERSION_NUMBER
4141 fi
4242
4343 - name : Check if release exists
@@ -46,10 +46,10 @@ jobs:
4646 sudo apt-add-repository https://cli.github.com/packages
4747 sudo apt update
4848 sudo apt-get install gh
49- if gh release list | grep $VERSION_NUM
49+ if gh release list | grep $VERSION_NUMBER
5050 then
51- echo "Deleting existing release for $VERSION_NUM "
52- gh release delete --yes $VERSION_NUM
51+ echo "Deleting existing release for $VERSION_NUMBER "
52+ gh release delete --yes $VERSION_NUMBER
5353 fi
5454
5555 add-sbom-and-tag-commit :
@@ -64,44 +64,58 @@ jobs:
6464 ref : ${{ github.event.inputs.commit_id }}
6565
6666 - name : Configure git identity
67+ env :
68+ ACTOR : ${{ github.actor }}
6769 run : |
68- git config --global user.name ${{ github.actor }}
69- git config --global user.email ${{ github.actor }} @users.noreply.github.com
70+ git config --global user.name "$ACTOR"
71+ git config --global user.email "$ACTOR" @users.noreply.github.com
7072
7173 - name : create a new branch that references commit id
72- run : git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
74+ env :
75+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
76+ COMMIT_ID : ${{ github.event.inputs.commit_id }}
77+ run : git checkout -b "$VERSION_NUMBER" "$COMMIT_ID"
7378
7479 - name : Update version number in source files
80+ env :
81+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
82+ REPO_NAME : ${{ github.event.repository.name }}
7583 run : |
7684 echo "${{ env.source_folder_list }}" | \
7785 xargs -n 1 sh -c \
7886 'find $1 -type f \( -name "*.c" -o -name "*.h" \) \
79- -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" {} +'
87+ -exec sed -i -b -E "0,/^ \* $REPO_NAME /s/^ \* $REPO_NAME. */ \* $REPO_NAME $VERSION_NUMBER /g" {} +'
8088 git add .
8189 git commit -m '[AUTO][RELEASE]: Update version number in source files'
82- git push -u origin ${{ github.event.inputs.version_number }}
90+ git push -u origin "$VERSION_NUMBER"
8391
8492 - name : Update version number in manifest.yml
93+ env :
94+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
8595 run : |
86- sed -i -b ' 0,/^version/s/^version.*/version: "${{ github.event.inputs.version_number }} "/g' ./manifest.yml
96+ sed -i -b " 0,/^version/s/^version.*/version: \"$VERSION_NUMBER\ "/g" ./manifest.yml
8797 git add .
8898 git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml'
89- git push -u origin ${{ github.event.inputs.version_number }}
99+ git push -u origin "$VERSION_NUMBER"
90100
91101 - name : Update version number in doxygen
102+ env :
103+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
92104 run : |
93- sed -i -b ' s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = ${{ github.event.inputs.version_number }}/g' ./docs/doxygen/config.doxyfile
105+ sed -i -b " s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $VERSION_NUMBER/g" ./docs/doxygen/config.doxyfile
94106 git add .
95107 git commit -m '[AUTO][RELEASE]: Update version number in doxygen'
96- git push -u origin ${{ github.event.inputs.version_number }}
108+ git push -u origin "$VERSION_NUMBER"
97109
98110 - name : Update MQTT version number macro
111+ env :
112+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
99113 if : ${{ github.event.repository.name == 'coreMQTT' }}
100114 run : |
101- sed -i -b ' s/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "${{ github.event.inputs.version_number }} "/g' source/include/core_mqtt.h
115+ sed -i -b " s/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION \"$VERSION_NUMBER\ "/g" source/include/core_mqtt.h
102116 git add .
103117 git commit -m '[AUTO][RELEASE]: Update version number macro in source/include/core_mqtt.h'
104- git push -u origin ${{ github.event.inputs.version_number }}
118+ git push -u origin "$VERSION_NUMBER"
105119
106120 - name : Generate SBOM
107121 uses : FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
@@ -110,22 +124,30 @@ jobs:
110124 source_path : ./source
111125
112126 - name : commit SBOM file
127+ env :
128+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
113129 run : |
114130 git add .
115131 git commit -m 'Update SBOM'
116- git push -u origin ${{ github.event.inputs.version_number }}
132+ git push -u origin "$VERSION_NUMBER"
117133
118134 - name : Tag Commit and Push to remote
135+ env :
136+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
137+ REPO_NAME : ${{ github.event.repository.name }}
119138 run : |
120- git tag ${{ github.event.inputs.version_number }} -a -m "${{ github.event.repository.name }} Library ${{ github.event.inputs.version_number }} "
139+ git tag "$VERSION_NUMBER" -a -m "$REPO_NAME Library $VERSION_NUMBER "
121140 git push origin --tags
122141
123142 - name : Verify tag on remote
143+ env :
144+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
145+ COMMIT_ID : ${{ github.event.inputs.commit_id }}
124146 run : |
125- git tag -d ${{ github.event.inputs.version_number }}
147+ git tag -d "$VERSION_NUMBER"
126148 git remote update
127- git checkout tags/${{ github.event.inputs.version_number }}
128- git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
149+ git checkout tags/"$VERSION_NUMBER"
150+ git diff "$COMMIT_ID" tags/"$VERSION_NUMBER"
129151
130152 create-zip :
131153 if : ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
@@ -144,82 +166,103 @@ jobs:
144166 submodules : recursive
145167
146168 - name : Checkout disabled submodules
169+ env :
170+ REPO_NAME : ${{ github.event.repository.name }}
147171 run : |
148- cd ${{ github.event.repository.name }}
172+ cd "$REPO_NAME"
149173 git submodule update --init --checkout --recursive
150174
151175 - name : Create ZIP
176+ env :
177+ REPO_NAME : ${{ github.event.repository.name }}
152178 run : |
153- zip -r ${{ env.repository_zip_name }} ${{ github.event.repository.name }} -x "*.git*"
179+ zip -r ${{ env.repository_zip_name }} "$REPO_NAME" -x "*.git*"
154180 ls ./
155181
156182 - name : Validate created ZIP
183+ env :
184+ REPO_NAME : ${{ github.event.repository.name }}
157185 run : |
158186 mkdir zip-check
159187 mv ${{ env.repository_zip_name }} zip-check
160188 cd zip-check
161189 unzip ${{ env.repository_zip_name }} -d ${{ env.repository_compressed_name }}
162190 ls ${{ env.repository_compressed_name }}
163- diff -r -x "*.git*" ${{ env.repository_compressed_name }}/${{ github.event.repository.name }} / ../${{ github.event.repository.name }} /
191+ diff -r -x "*.git*" ${{ env.repository_compressed_name }}/"$REPO_NAME" / ../"$REPO_NAME" /
164192 cd ../
165193
166194 - name : Check version number in source files
195+ env :
196+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
197+ REPO_NAME : ${{ github.event.repository.name }}
167198 run : |
168- cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
199+ cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME"
169200
170201 # List all the *.h *.c files in <source_folder_list>
171202 SOURCE_FILE_LIST=$( echo "${{ env.source_folder_list }}" | \
172203 xargs -n 1 sh -c 'find $1 -type f \( -name "*.c" -o -name "*.h" \)' )
173204
174205 # List all the files which contain " * <repository_name>.*" in SOURCE_FILE_LIST
175- SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* ${{ github.event.repository.name }} .*" $SOURCE_FILE_LIST )
206+ SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* $REPO_NAME .*" $SOURCE_FILE_LIST )
176207
177208 # Compare the <version_number> with input version number in files in SOURCE_FILE_LIST
178209 echo $SOURCE_FILE_WITH_VERSION_LIST | xargs -I{} sh -c \
179- 'grep -x " \* ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} " {} && \
180- echo {} : match ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} || \
181- { echo "{} : ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} not found"; exit 255; }'
210+ 'grep -x " \* $REPO_NAME $VERSION_NUMBER " {} && \
211+ echo {} : match "$REPO_NAME" "$VERSION_NUMBER" || \
212+ { echo "{} : $REPO_NAME $VERSION_NUMBER not found"; exit 255; }'
182213
183214 - name : Check version number in doxygen
215+ env :
216+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
217+ REPO_NAME : ${{ github.event.repository.name }}
184218 run : |
185- cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
219+ cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME"
186220
187221 # find "PROJECT_NUMBER = <version_number>"
188222 DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }');
189223
190224 # compare the <version_number> with input version number
191- [[ $DOXYGEN_VERSION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \
192- && echo "config.doxyfile : match ${{ github.event.inputs.version_number }}" \
193- || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; }
225+ echo "Comparing $DOXYGEN_VERSION_NUMBER & $VERSION_NUMBER"
226+ [[ $DOXYGEN_VERSION_NUMBER == $VERSION_NUMBER ]] \
227+ && echo "config.doxyfile : match $VERSION_NUMBER" \
228+ || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match $VERSION_NUMBER"; exit 255; }
194229
195230 - name : Check version number in manifest.yml
231+ env :
232+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
233+ REPO_NAME : ${{ github.event.repository.name }}
196234 run : |
197- cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
235+ cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME"
198236
199237 # find the first occurence of "version: <version_number>" and comare the <version_number> with input version number
200238 MANIFEST_VESION_NUMBER=$( grep -m 1 -E "^version:[ ]*\".*\"[ ]*" manifest.yml | awk -F: '{ gsub(" ","",$2); gsub("\"","",$2); print $2 }' );
201239
202240 # compare the <version_number> with input version number
203- [[ $MANIFEST_VESION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \
204- && echo "manifest.yml : match ${{ github.event.inputs.version_number }} " \
205- || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match ${{ github.event.inputs.version_number }} "; exit 255; }
241+ [[ $MANIFEST_VESION_NUMBER == $VERSION_NUMBER ]] \
242+ && echo "manifest.yml : match $VERSION_NUMBER " \
243+ || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match $VERSION_NUMBER "; exit 255; }
206244
207245 - name : Check MQTT version number macro in header file
246+ env :
247+ VERSION_NUMBER : ${{ github.event.inputs.version_number }}
248+ REPO_NAME : ${{ github.event.repository.name }}
208249 if : ${{ github.event.repository.name == 'coreMQTT' }}
209250 run : |
210- cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
251+ cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME"
211252
212253 # find "#define MQTT_LIBRARY_VERSION <version_number>" in core_mqtt.h
213254 MACRO_VERSION_NUMBER=$(grep -x "^\#define[ ]*MQTT_LIBRARY_VERSION[ ]*\".*\"[ ]*" source/include/core_mqtt.h | awk '{gsub("\"","",$3); print $3 }');
214255
215256 # compare the <version_number> with input version number
216- [[ $MACRO_VERSION_NUMBER == "${{ github.event.inputs.version_number }} " ]] \
217- && echo "core_mqtt.h : match ${{ github.event.inputs.version_number }} " \
218- || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match ${{ github.event.inputs.version_number }} "; exit 255; }
257+ [[ $MACRO_VERSION_NUMBER == "$VERSION_NUMBER " ]] \
258+ && echo "core_mqtt.h : match $VERSION_NUMBER " \
259+ || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match $VERSION_NUMBER "; exit 255; }
219260
220261 - name : Build
262+ env :
263+ REPO_NAME : ${{ github.event.repository.name }}
221264 run : |
222- cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
265+ cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME"
223266 sudo apt-get install -y lcov
224267 cmake -S test -B build/ \
225268 -G "Unix Makefiles" \
@@ -229,8 +272,10 @@ jobs:
229272 make -C build/ all
230273
231274 - name : Test
275+ env :
276+ REPO_NAME : ${{ github.event.repository.name }}
232277 run : |
233- cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }} /build/
278+ cd zip-check/${{ env.repository_compressed_name }}/"$REPO_NAME" /build/
234279 ctest -E system --output-on-failure
235280 cd ..
236281
@@ -287,3 +332,4 @@ jobs:
287332 asset_path : ./${{ env.repository_zip_name }}
288333 asset_name : ${{ env.repository_zip_name }}
289334 asset_content_type : application/zip
335+
0 commit comments