9
9
version_number :
10
10
description : ' Release Version Number (Eg, v1.0.0)'
11
11
required : true
12
+ delete_existing_tag_release :
13
+ description : ' Is this a re-release of existing tag/release? (Default: false)'
14
+ default : ' false'
15
+ required : false
16
+
17
+ env :
18
+ repository_compressed_name : ${{ github.event.repository.name }}-${{ github.event.inputs.version_number }}
19
+ repository_zip_name : ${{ github.event.repository.name }}-${{ github.event.inputs.version_number }}.zip
20
+ # Some library use different name for library and repository. Version number may use library_name in source file.
21
+ library_name : " FreeRTOS+TCP"
22
+ # Source folder list for version number updates
23
+ source_folder_list : " source test"
12
24
13
25
jobs :
14
- tag-commit :
26
+ clean-existing-tag-and-release :
27
+ if : ${{ github.event.inputs.delete_existing_tag_release == 'true' }}
28
+ runs-on : ubuntu-latest
29
+ env :
30
+ VERSION_NUM : ${{ github.event.inputs.version_number }}
31
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
+ steps :
33
+ - name : Checkout code
34
+ uses : actions/checkout@v4
35
+
36
+ - name : Check if tag exists
37
+ run : |
38
+ git fetch origin
39
+ if git tag --list $VERSION_NUM
40
+ then
41
+ echo "Deleting existing tag for $VERSION_NUM"
42
+ git push origin --delete tags/$VERSION_NUM
43
+ fi
44
+
45
+ - name : Check if release exists
46
+ run : |
47
+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 23F3D4EA75716059
48
+ sudo apt-add-repository https://cli.github.com/packages
49
+ sudo apt update
50
+ sudo apt-get install gh
51
+ if gh release list | grep $VERSION_NUM
52
+ then
53
+ echo "Deleting existing release for $VERSION_NUM"
54
+ gh release delete --yes $VERSION_NUM
55
+ fi
56
+
57
+ add-sbom-and-tag-commit :
58
+ if : ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
59
+ needs : clean-existing-tag-and-release
15
60
name : Tag commit
16
61
runs-on : ubuntu-latest
17
62
steps :
18
63
- name : Checkout code
19
64
uses : actions/checkout@v4
20
65
with :
21
66
ref : ${{ github.event.inputs.commit_id }}
67
+
22
68
- name : Configure git identity
23
69
run : |
24
70
git config --global user.name ${{ github.actor }}
25
71
git config --global user.email ${{ github.actor }}@users.noreply.github.com
72
+
26
73
- name : create a new branch that references commit id
27
74
run : git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
75
+
76
+ - name : Update version number in source files
77
+ run : |
78
+ echo "${{ env.source_folder_list }}" | \
79
+ xargs -n 1 sh -c \
80
+ 'find $1 -type f \( -name "*.c" -o -name "*.h" \) \
81
+ -exec sed -i -b -E "0,/^ \* ${{ env.library_name }}/s/^ \* ${{ env.library_name }}.*/ \* ${{ env.library_name }} ${{ github.event.inputs.version_number }}/g" {} +'
82
+ git add .
83
+ git commit -m '[AUTO][RELEASE]: Update version number in source files'
84
+ git push -u origin ${{ github.event.inputs.version_number }}
85
+
86
+ - name : Update version number in manifest.yml
87
+ run : |
88
+ sed -i -b '0,/^version/s/^version.*/version: "${{ github.event.inputs.version_number }}"/g' ./manifest.yml
89
+ git add .
90
+ git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml'
91
+ git push -u origin ${{ github.event.inputs.version_number }}
92
+
93
+ - name : Update version number in doxygen
94
+ run : |
95
+ sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = ${{ github.event.inputs.version_number }}/g' ./docs/doxygen/config.doxyfile
96
+ git add .
97
+ git commit -m '[AUTO][RELEASE]: Update version number in doxygen'
98
+ git push -u origin ${{ github.event.inputs.version_number }}
99
+
100
+ - name : Update MQTT version number macro
101
+ if : ${{ github.event.repository.name == 'coreMQTT' }}
102
+ run : |
103
+ sed -i -b 's/^\#define MQTT_LIBRARY_VERSION .*/\#define MQTT_LIBRARY_VERSION "${{ github.event.inputs.version_number }}"/g' source/include/core_mqtt.h
104
+ git add .
105
+ git commit -m '[AUTO][RELEASE]: Update version number macro in source/include/core_mqtt.h'
106
+ git push -u origin ${{ github.event.inputs.version_number }}
107
+
28
108
- name : Generate SBOM
29
109
uses : FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
30
110
with :
31
111
repo_path : ./
32
112
source_path : ./source
113
+
33
114
- name : commit SBOM file
34
115
run : |
35
116
git add .
36
117
git commit -m 'Update SBOM'
37
118
git push -u origin ${{ github.event.inputs.version_number }}
119
+
38
120
- name : Tag Commit and Push to remote
39
121
run : |
40
- git tag ${{ github.event.inputs.version_number }} -a -m "FreeRTOS-Plus-TCP Library ${{ github.event.inputs.version_number }}"
122
+ git tag ${{ github.event.inputs.version_number }} -a -m "${{ github.event.repository.name }} Library ${{ github.event.inputs.version_number }}"
41
123
git push origin --tags
124
+
42
125
- name : Verify tag on remote
43
126
run : |
44
127
git tag -d ${{ github.event.inputs.version_number }}
45
128
git remote update
46
129
git checkout tags/${{ github.event.inputs.version_number }}
47
130
git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
131
+
48
132
create-zip :
49
- needs : tag-commit
133
+ if : ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
134
+ needs : add-sbom-and-tag-commit
50
135
name : Create ZIP and verify package for release asset.
51
136
runs-on : ubuntu-latest
52
137
steps :
53
138
- name : Install ZIP tools
54
139
run : sudo apt-get install zip unzip
140
+
55
141
- name : Checkout code
56
142
uses : actions/checkout@v4
57
143
with :
58
- ref : ${{ github.event.inputs.commit_id }}
59
- path : FreeRTOS-Plus-TCP
144
+ ref : ${{ github.event.inputs.version_number }}
145
+ path : ${{ github.event.repository.name }}
60
146
submodules : recursive
147
+
61
148
- name : Checkout disabled submodules
62
149
run : |
63
- cd FreeRTOS-Plus-TCP
150
+ cd ${{ github.event.repository.name }}
64
151
git submodule update --init --checkout --recursive
152
+
65
153
- name : Create ZIP
66
154
run : |
67
- zip -r FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}.zip FreeRTOS-Plus-TCP -x "*.git*"
155
+ zip -r ${{ env.repository_zip_name }} ${{ github.event.repository.name }} -x "*.git*"
68
156
ls ./
157
+
69
158
- name : Validate created ZIP
70
159
run : |
71
160
mkdir zip-check
72
- mv FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}.zip zip-check
161
+ mv ${{ env.repository_zip_name }} zip-check
73
162
cd zip-check
74
- unzip FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}.zip -d FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}
75
- ls FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}
76
- diff -r -x "*.git*" FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}/FreeRTOS-Plus-TCP/ ../FreeRTOS-Plus-TCP /
163
+ unzip ${{ env.repository_zip_name }} -d ${{ env.repository_compressed_name }}
164
+ ls ${{ env.repository_compressed_name }}
165
+ diff -r -x "*.git*" ${{ env.repository_compressed_name }}/${{ github.event.repository.name }}/ ../${{ github.event.repository.name }} /
77
166
cd ../
167
+
168
+ - name : Check version number in source files
169
+ run : |
170
+ cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
171
+
172
+ # List all the *.h *.c files in <source_folder_list>
173
+ SOURCE_FILE_LIST=$( echo "${{ env.source_folder_list }}" | \
174
+ xargs -n 1 sh -c 'find $1 -type f \( -name "*.c" -o -name "*.h" \)' )
175
+
176
+ # List all the files which contain " * <repository_name>.*" in SOURCE_FILE_LIST
177
+ SOURCE_FILE_WITH_VERSION_LIST=$( grep -l " \* ${{ github.event.repository.name }}.*" $SOURCE_FILE_LIST )
178
+
179
+ # Compare the <version_number> with input version number in files in SOURCE_FILE_LIST
180
+ echo $SOURCE_FILE_WITH_VERSION_LIST | xargs -I{} sh -c \
181
+ 'grep -x " \* ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }}" {} && \
182
+ echo {} : match ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} || \
183
+ { echo "{} : ${{ github.event.repository.name }} ${{ github.event.inputs.version_number }} not found"; exit 255; }'
184
+
185
+ - name : Check version number in doxygen
186
+ run : |
187
+ cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
188
+
189
+ # find "PROJECT_NUMBER = <version_number>"
190
+ DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }');
191
+
192
+ # compare the <version_number> with input version number
193
+ [[ $DOXYGEN_VERSION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \
194
+ && echo "config.doxyfile : match ${{ github.event.inputs.version_number }}" \
195
+ || { echo "config.doxyfile : $DOXYGEN_VERSION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; }
196
+
197
+ - name : Check version number in manifest.yml
198
+ run : |
199
+ cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
200
+
201
+ # find the first occurence of "version: <version_number>" and comare the <version_number> with input version number
202
+ MANIFEST_VESION_NUMBER=$( grep -m 1 -E "^version:[ ]*\".*\"[ ]*" manifest.yml | awk -F: '{ gsub(" ","",$2); gsub("\"","",$2); print $2 }' );
203
+
204
+ # compare the <version_number> with input version number
205
+ [[ $MANIFEST_VESION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \
206
+ && echo "manifest.yml : match ${{ github.event.inputs.version_number }}" \
207
+ || { echo "manifest.yml : $MANIFEST_VESION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; }
208
+
209
+ - name : Check MQTT version number macro in header file
210
+ if : ${{ github.event.repository.name == 'coreMQTT' }}
211
+ run : |
212
+ cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
213
+
214
+ # find "#define MQTT_LIBRARY_VERSION <version_number>" in core_mqtt.h
215
+ MACRO_VERSION_NUMBER=$(grep -x "^\#define[ ]*MQTT_LIBRARY_VERSION[ ]*\".*\"[ ]*" source/include/core_mqtt.h | awk '{gsub("\"","",$3); print $3 }');
216
+
217
+ # compare the <version_number> with input version number
218
+ [[ $MACRO_VERSION_NUMBER == "${{ github.event.inputs.version_number }}" ]] \
219
+ && echo "core_mqtt.h : match ${{ github.event.inputs.version_number }}" \
220
+ || { echo "core_mqtt.h : $MACRO_VERSION_NUMBER doesn't match ${{ github.event.inputs.version_number }}"; exit 255; }
221
+
78
222
- name : Build
79
223
run : |
80
- cd zip-check/FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}/FreeRTOS-Plus-TCP
224
+ cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
81
225
sudo apt-get install -y lcov
82
226
sudo apt-get install unifdef
83
227
cmake -S test/unit-test -B test/unit-test/build/
84
228
make -C test/unit-test/build/ all
85
229
- name : Test
86
230
run : |
87
- cd zip-check/FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}/FreeRTOS-Plus-TCP
231
+ cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
88
232
pushd test/unit-test/build/
89
233
ctest -E system --output-on-failure
90
234
popd
91
235
make -C test/unit-test/build/ coverage
92
236
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info
93
237
cd ..
238
+
94
239
- name : Create artifact of ZIP
95
240
uses : actions/upload-artifact@v4
96
241
with :
97
- name : FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
98
- path : zip-check/FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
242
+ name : ${{ env.repository_zip_name }}
243
+ path : zip-check/${{ env.repository_zip_name }}
244
+
99
245
deploy-doxygen :
100
- needs : tag-commit
246
+ needs : add-sbom-and-tag-commit
247
+ if : ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
101
248
name : Deploy doxygen documentation
102
249
runs-on : ubuntu-latest
103
250
steps :
@@ -106,10 +253,12 @@ jobs:
106
253
with :
107
254
ref : ${{ github.event.inputs.version_number }}
108
255
add_release : " true"
256
+
109
257
create-release :
110
258
needs :
111
259
- create-zip
112
260
- deploy-doxygen
261
+ if : ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
113
262
name : Create Release and Upload Release Asset
114
263
runs-on : ubuntu-latest
115
264
steps :
@@ -121,22 +270,24 @@ jobs:
121
270
with :
122
271
tag_name : ${{ github.event.inputs.version_number }}
123
272
release_name : ${{ github.event.inputs.version_number }}
124
- body : Release ${{ github.event.inputs.version_number }} of the FreeRTOS-Plus-TCP Library.
273
+ body : Release ${{ github.event.inputs.version_number }} of the ${{ github.event.repository.name }} Library.
125
274
draft : false
126
275
prerelease : false
276
+
127
277
- name : Download ZIP artifact
128
278
uses : actions/download-artifact@v4
129
279
with :
130
- name : FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
280
+ name : ${{ env.repository_zip_name }}
281
+
131
282
- name : Upload Release Asset
132
283
id : upload-release-asset
133
284
uses : actions/upload-release-asset@v1
134
285
env :
135
286
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
136
287
with :
137
288
upload_url : ${{ steps.create_release.outputs.upload_url }}
138
- asset_path : ./FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}.zip
139
- asset_name : FreeRTOS-Plus-TCP- ${{ github.event.inputs.version_number }}.zip
289
+ asset_path : ./${{ env.repository_zip_name }}
290
+ asset_name : ${{ env.repository_zip_name }}
140
291
asset_content_type : application/zip
141
292
cleanup :
142
293
needs :
0 commit comments