Skip to content

Commit 9b993a6

Browse files
authored
Update release action for version number (#297)
<!--- Title --> Description ----------- * Update the release action for version number include the following files - docs/doxygen/config.doxyfile - PROJECT_NUMBER - manifest.yml file - version - source file - version header - core_mqtt.h - version number * Add version number check in "Create ZIP and verify package for release asset" steps. Including the following - docs/doxygen/config.doxyfile - PROJECT_NUMBER - manifest.yml file - version - source file - version header - core_mqtt.h - version number * Update all the version number to "v2.3.0+" and "\<DEVELOPMENT BRANCH\>" Test Steps ----------- Using release action to create release should update the following * source/include/core_mqtt.h version number * source files header version number * doxygen version number * manifest.yml number * SBOM file Tested in personal fork without problem : https://github.com/FreshDevGo/coreMQTT/actions/runs/9885707328/job/27304218049 Test with wrong source file version number : https://github.com/FreshDevGo/coreMQTT/actions/runs/9885727002/job/27304274003 Test with wrong manifest.yml version number : https://github.com/FreshDevGo/coreMQTT/actions/runs/9885726029/job/27304270303 Test with wrong doxygen version number : https://github.com/FreshDevGo/coreMQTT/actions/runs/9885723302/job/27304269170 Test with wrong version number macro in core_mqtt.h : https://github.com/FreshDevGo/coreMQTT/actions/runs/9885724835/job/27304268841 Checklist: ---------- <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have tested my changes. No regression in existing tests. - [ ] ~~I have modified and/or added unit-tests to cover the code changes in this Pull Request.~~ Related Issue ----------- <!-- If any, please provide issue ID. --> By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 8b3abb7 commit 9b993a6

File tree

51 files changed

+190
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+190
-73
lines changed

.github/workflows/release.yml

Lines changed: 136 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ on:
1313
description: 'Is this a re-release of existing tag/release? (Default: false)'
1414
default: 'false'
1515
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+
# Source folder list for version number updates
21+
source_folder_list: "source test"
22+
1623
jobs:
1724
clean-existing-tag-and-release:
1825
if: ${{ github.event.inputs.delete_existing_tag_release == 'true' }}
@@ -22,7 +29,8 @@ jobs:
2229
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2330
steps:
2431
- name: Checkout code
25-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
33+
2634
- name: Check if tag exists
2735
run: |
2836
git fetch origin
@@ -31,6 +39,7 @@ jobs:
3139
echo "Deleting existing tag for $VERSION_NUM"
3240
git push origin --delete tags/$VERSION_NUM
3341
fi
42+
3443
- name: Check if release exists
3544
run: |
3645
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 23F3D4EA75716059
@@ -42,42 +51,82 @@ jobs:
4251
echo "Deleting existing release for $VERSION_NUM"
4352
gh release delete --yes $VERSION_NUM
4453
fi
54+
4555
add-sbom-and-tag-commit:
4656
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
4757
needs: clean-existing-tag-and-release
4858
name: Tag commit
4959
runs-on: ubuntu-latest
5060
steps:
5161
- name: Checkout code
52-
uses: actions/checkout@v3
62+
uses: actions/checkout@v4
5363
with:
5464
ref: ${{ github.event.inputs.commit_id }}
65+
5566
- name: Configure git identity
5667
run: |
5768
git config --global user.name ${{ github.actor }}
5869
git config --global user.email ${{ github.actor }}@users.noreply.github.com
70+
5971
- name: create a new branch that references commit id
6072
run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
73+
74+
- name: Update version number in source files
75+
run: |
76+
echo "${{ env.source_folder_list }}" | \
77+
xargs -n 1 sh -c \
78+
'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" {} +'
80+
git add .
81+
git commit -m '[AUTO][RELEASE]: Update version number in source files'
82+
git push -u origin ${{ github.event.inputs.version_number }}
83+
84+
- name : Update version number in manifest.yml
85+
run: |
86+
sed -i -b '0,/^version/s/^version.*/version: "${{ github.event.inputs.version_number }}"/g' ./manifest.yml
87+
git add .
88+
git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml'
89+
git push -u origin ${{ github.event.inputs.version_number }}
90+
91+
- name : Update version number in doxygen
92+
run: |
93+
sed -i -b 's/PROJECT_NUMBER *=.*/PROJECT_NUMBER = ${{ github.event.inputs.version_number }}/g' ./docs/doxygen/config.doxyfile
94+
git add .
95+
git commit -m '[AUTO][RELEASE]: Update version number in doxygen'
96+
git push -u origin ${{ github.event.inputs.version_number }}
97+
98+
- name : Update MQTT version number macro
99+
if: ${{ github.event.repository.name == 'coreMQTT' }}
100+
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
102+
git add .
103+
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 }}
105+
61106
- name: Generate SBOM
62107
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
63108
with:
64109
repo_path: ./
65110
source_path: ./source
111+
66112
- name: commit SBOM file
67113
run: |
68114
git add .
69115
git commit -m 'Update SBOM'
70116
git push -u origin ${{ github.event.inputs.version_number }}
117+
71118
- name: Tag Commit and Push to remote
72119
run: |
73-
git tag ${{ github.event.inputs.version_number }} -a -m "coreMQTT Library ${{ github.event.inputs.version_number }}"
120+
git tag ${{ github.event.inputs.version_number }} -a -m "${{ github.event.repository.name }} Library ${{ github.event.inputs.version_number }}"
74121
git push origin --tags
122+
75123
- name: Verify tag on remote
76124
run: |
77125
git tag -d ${{ github.event.inputs.version_number }}
78126
git remote update
79127
git checkout tags/${{ github.event.inputs.version_number }}
80128
git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
129+
81130
create-zip:
82131
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
83132
needs: add-sbom-and-tag-commit
@@ -86,49 +135,111 @@ jobs:
86135
steps:
87136
- name: Install ZIP tools
88137
run: sudo apt-get install zip unzip
138+
89139
- name: Checkout code
90-
uses: actions/checkout@v3
140+
uses: actions/checkout@v4
91141
with:
92-
ref: ${{ github.event.inputs.commit_id }}
93-
path: coreMQTT
142+
ref: ${{ github.event.inputs.version_number }}
143+
path: ${{ github.event.repository.name }}
94144
submodules: recursive
145+
95146
- name: Checkout disabled submodules
96147
run: |
97-
cd coreMQTT
148+
cd ${{ github.event.repository.name }}
98149
git submodule update --init --checkout --recursive
150+
99151
- name: Create ZIP
100152
run: |
101-
zip -r coreMQTT-${{ github.event.inputs.version_number }}.zip coreMQTT -x "*.git*"
153+
zip -r ${{ env.repository_zip_name }} ${{ github.event.repository.name }} -x "*.git*"
102154
ls ./
155+
103156
- name: Validate created ZIP
104157
run: |
105158
mkdir zip-check
106-
mv coreMQTT-${{ github.event.inputs.version_number }}.zip zip-check
159+
mv ${{ env.repository_zip_name }} zip-check
107160
cd zip-check
108-
unzip coreMQTT-${{ github.event.inputs.version_number }}.zip -d coreMQTT-${{ github.event.inputs.version_number }}
109-
ls coreMQTT-${{ github.event.inputs.version_number }}
110-
diff -r -x "*.git*" coreMQTT-${{ github.event.inputs.version_number }}/coreMQTT/ ../coreMQTT/
161+
unzip ${{ env.repository_zip_name }} -d ${{ env.repository_compressed_name }}
162+
ls ${{ env.repository_compressed_name }}
163+
diff -r -x "*.git*" ${{ env.repository_compressed_name }}/${{ github.event.repository.name }}/ ../${{ github.event.repository.name }}/
111164
cd ../
165+
166+
- name: Check version number in source files
167+
run: |
168+
cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
169+
170+
# List all the *.h *.c files in <source_folder_list>
171+
SOURCE_FILE_LIST=$( echo "${{ env.source_folder_list }}" | \
172+
xargs -n 1 sh -c 'find $1 -type f \( -name "*.c" -o -name "*.h" \)' )
173+
174+
# 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 )
176+
177+
# Compare the <version_number> with input version number in files in SOURCE_FILE_LIST
178+
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; }'
182+
183+
- name: Check version number in doxygen
184+
run: |
185+
cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
186+
187+
# find "PROJECT_NUMBER = <version_number>"
188+
DOXYGEN_VERSION_NUMBER=$(grep -x "[ ]*PROJECT_NUMBER[ ]*=[ ]*[^ ]*[ ]*" docs/doxygen/config.doxyfile | awk -F= '{gsub(" ","",$2); print $2 }');
189+
190+
# 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; }
194+
195+
- name: Check version number in manifest.yml
196+
run: |
197+
cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
198+
199+
# find the first occurence of "version: <version_number>" and comare the <version_number> with input version number
200+
MANIFEST_VESION_NUMBER=$( grep -m 1 -E "^version:[ ]*\".*\"[ ]*" manifest.yml | awk -F: '{ gsub(" ","",$2); gsub("\"","",$2); print $2 }' );
201+
202+
# 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; }
206+
207+
- name: Check MQTT version number macro in header file
208+
if: ${{ github.event.repository.name == 'coreMQTT' }}
209+
run: |
210+
cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
211+
212+
# find "#define MQTT_LIBRARY_VERSION <version_number>" in core_mqtt.h
213+
MACRO_VERSION_NUMBER=$(grep -x "^\#define[ ]*MQTT_LIBRARY_VERSION[ ]*\".*\"[ ]*" source/include/core_mqtt.h | awk '{gsub("\"","",$3); print $3 }');
214+
215+
# 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; }
219+
112220
- name: Build
113221
run: |
114-
cd zip-check/coreMQTT-${{ github.event.inputs.version_number }}/coreMQTT
222+
cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}
115223
sudo apt-get install -y lcov
116224
cmake -S test -B build/ \
117225
-G "Unix Makefiles" \
118226
-DCMAKE_BUILD_TYPE=Debug \
119227
-DBUILD_CLONE_SUBMODULES=ON \
120228
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG'
121229
make -C build/ all
230+
122231
- name: Test
123232
run: |
124-
cd zip-check/coreMQTT-${{ github.event.inputs.version_number }}/coreMQTT/build/
233+
cd zip-check/${{ env.repository_compressed_name }}/${{ github.event.repository.name }}/build/
125234
ctest -E system --output-on-failure
126235
cd ..
236+
127237
- name: Create artifact of ZIP
128-
uses: actions/upload-artifact@v2
238+
uses: actions/upload-artifact@v4
129239
with:
130-
name: coreMQTT-${{ github.event.inputs.version_number }}.zip
131-
path: zip-check/coreMQTT-${{ github.event.inputs.version_number }}.zip
240+
name: ${{ env.repository_zip_name }}
241+
path: zip-check/${{ env.repository_zip_name }}
242+
132243
deploy-doxygen:
133244
needs: add-sbom-and-tag-commit
134245
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
@@ -140,6 +251,7 @@ jobs:
140251
with:
141252
ref: ${{ github.event.inputs.version_number }}
142253
add_release: "true"
254+
143255
create-release:
144256
needs:
145257
- create-zip
@@ -156,20 +268,22 @@ jobs:
156268
with:
157269
tag_name: ${{ github.event.inputs.version_number }}
158270
release_name: ${{ github.event.inputs.version_number }}
159-
body: Release ${{ github.event.inputs.version_number }} of the coreMQTT Library.
271+
body: Release ${{ github.event.inputs.version_number }} of the ${{ github.event.repository.name }} Library.
160272
draft: false
161273
prerelease: false
274+
162275
- name: Download ZIP artifact
163-
uses: actions/download-artifact@v2
276+
uses: actions/download-artifact@v4
164277
with:
165-
name: coreMQTT-${{ github.event.inputs.version_number }}.zip
278+
name: ${{ env.repository_zip_name }}
279+
166280
- name: Upload Release Asset
167281
id: upload-release-asset
168282
uses: actions/upload-release-asset@v1
169283
env:
170284
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171285
with:
172286
upload_url: ${{ steps.create_release.outputs.upload_url }}
173-
asset_path: ./coreMQTT-${{ github.event.inputs.version_number }}.zip
174-
asset_name: coreMQTT-${{ github.event.inputs.version_number }}.zip
287+
asset_path: ./${{ env.repository_zip_name }}
288+
asset_name: ${{ env.repository_zip_name }}
175289
asset_content_type: application/zip

docs/doxygen/config.doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = coreMQTT
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = v2.3.0
51+
PROJECT_NUMBER = v2.3.0+
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name : "coreMQTT"
2-
version: "v2.3.0"
2+
version: "v2.3.0+"
33
description: |
44
"Client implementation of the MQTT 3.1.1 specification for embedded devices.\n"
55
license: "MIT"

source/core_mqtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT

source/core_mqtt_serializer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT

source/core_mqtt_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT

source/include/core_mqtt.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT
@@ -44,8 +44,11 @@
4444
/**
4545
* @cond DOXYGEN_IGNORE
4646
* The current version of this library.
47+
*
48+
* If MQTT_LIBRARY_VERSION ends with + it represents the version in development
49+
* after the numbered release.
4750
*/
48-
#define MQTT_LIBRARY_VERSION "v2.1.0"
51+
#define MQTT_LIBRARY_VERSION "v2.3.0+"
4952
/** @endcond */
5053

5154
/**

source/include/core_mqtt_config_defaults.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT

source/include/core_mqtt_serializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT

source/include/core_mqtt_state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* coreMQTT v2.3.0
2+
* coreMQTT <DEVELOPMENT BRANCH>
33
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT

0 commit comments

Comments
 (0)