Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release action for version number #297

Merged
merged 22 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 83 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ on:
description: 'Is this a re-release of existing tag/release? (Default: false)'
default: 'false'
required: false

env:
repository_name: "coreMQTT"
repository_compressed_name: coreMQTT-${{ github.event.inputs.version_number }}
repository_zip_name: coreMQTT-${{ github.event.inputs.version_number }}.zip
# Source folder list for version number updates
source_folder_list: "source test"

jobs:
clean-existing-tag-and-release:
if: ${{ github.event.inputs.delete_existing_tag_release == 'true' }}
Expand All @@ -22,7 +30,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check if tag exists
run: |
git fetch origin
Expand All @@ -31,6 +40,7 @@ jobs:
echo "Deleting existing tag for $VERSION_NUM"
git push origin --delete tags/$VERSION_NUM
fi

- name: Check if release exists
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 23F3D4EA75716059
Expand All @@ -42,42 +52,82 @@ jobs:
echo "Deleting existing release for $VERSION_NUM"
gh release delete --yes $VERSION_NUM
fi

add-sbom-and-tag-commit:
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
needs: clean-existing-tag-and-release
name: Tag commit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.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

- name: create a new branch that references commit id
run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.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,/^ \* ${{ env.repository_name }}/s/^ \* ${{ env.repository_name }}.*/ \* ${{ env.repository_name }} ${{ github.event.inputs.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 }}

- name : Update version number in manifest.yml
run: |
sed -i -b '0,/^version/s/^version.*/version: "${{ github.event.inputs.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 }}

- 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
git add .
git commit -m '[AUTO][RELEASE]: Update version number in doxygen'
git push -u origin ${{ github.event.inputs.version_number }}

- name : Update MQTT version number macro
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
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 }}

- name: Generate SBOM
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
with:
repo_path: ./
source_path: ./source

- name: commit SBOM file
run: |
git add .
git commit -m 'Update SBOM'
git push -u origin ${{ github.event.inputs.version_number }}

- name: Tag Commit and Push to remote
run: |
git tag ${{ github.event.inputs.version_number }} -a -m "coreMQTT Library ${{ github.event.inputs.version_number }}"
git tag ${{ github.event.inputs.version_number }} -a -m "${{ env.repository_name }} Library ${{ github.event.inputs.version_number }}"
git push origin --tags

- name: Verify tag on remote
run: |
git tag -d ${{ github.event.inputs.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 }}

create-zip:
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
needs: add-sbom-and-tag-commit
Expand All @@ -86,49 +136,57 @@ jobs:
steps:
- name: Install ZIP tools
run: sudo apt-get install zip unzip

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_id }}
path: coreMQTT
ref: ${{ github.event.inputs.version_number }}
path: ${{ env.repository_name }}
submodules: recursive

- name: Checkout disabled submodules
run: |
cd coreMQTT
cd ${{ env.repository_name }}
git submodule update --init --checkout --recursive

- name: Create ZIP
run: |
zip -r coreMQTT-${{ github.event.inputs.version_number }}.zip coreMQTT -x "*.git*"
zip -r ${{ env.repository_zip_name }} ${{ env.repository_name }} -x "*.git*"
ls ./

- name: Validate created ZIP
run: |
mkdir zip-check
mv coreMQTT-${{ github.event.inputs.version_number }}.zip zip-check
mv ${{ env.repository_zip_name }} zip-check
cd zip-check
unzip coreMQTT-${{ github.event.inputs.version_number }}.zip -d coreMQTT-${{ github.event.inputs.version_number }}
ls coreMQTT-${{ github.event.inputs.version_number }}
diff -r -x "*.git*" coreMQTT-${{ github.event.inputs.version_number }}/coreMQTT/ ../coreMQTT/
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 }}/
cd ../

- name: Build
run: |
cd zip-check/coreMQTT-${{ github.event.inputs.version_number }}/coreMQTT
cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }}
sudo apt-get install -y lcov
cmake -S test -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_CLONE_SUBMODULES=ON \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG'
make -C build/ all

- name: Test
run: |
cd zip-check/coreMQTT-${{ github.event.inputs.version_number }}/coreMQTT/build/
cd zip-check/${{ env.repository_compressed_name }}/${{ env.repository_name }}/build/
ctest -E system --output-on-failure
cd ..

- name: Create artifact of ZIP
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: coreMQTT-${{ github.event.inputs.version_number }}.zip
path: zip-check/coreMQTT-${{ github.event.inputs.version_number }}.zip
name: ${{ env.repository_zip_name }}
path: zip-check/${{ env.repository_zip_name }}

deploy-doxygen:
needs: add-sbom-and-tag-commit
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
Expand All @@ -140,6 +198,7 @@ jobs:
with:
ref: ${{ github.event.inputs.version_number }}
add_release: "true"

create-release:
needs:
- create-zip
Expand All @@ -156,20 +215,22 @@ jobs:
with:
tag_name: ${{ github.event.inputs.version_number }}
release_name: ${{ github.event.inputs.version_number }}
body: Release ${{ github.event.inputs.version_number }} of the coreMQTT Library.
body: Release ${{ github.event.inputs.version_number }} of the ${{ env.repository_name }} Library.
draft: false
prerelease: false

- name: Download ZIP artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: coreMQTT-${{ github.event.inputs.version_number }}.zip
name: ${{ env.repository_zip_name }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./coreMQTT-${{ github.event.inputs.version_number }}.zip
asset_name: coreMQTT-${{ github.event.inputs.version_number }}.zip
asset_path: ./${{ env.repository_zip_name }}
asset_name: ${{ env.repository_zip_name }}
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion docs/doxygen/config.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.0
PROJECT_NUMBER = v2.3.0+

# 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
Expand Down
2 changes: 1 addition & 1 deletion manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name : "coreMQTT"
version: "v2.3.0"
version: "v2.3.0+"
description: |
"Client implementation of the MQTT 3.1.1 specification for embedded devices.\n"
license: "MIT"
2 changes: 1 addition & 1 deletion source/core_mqtt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion source/core_mqtt_serializer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion source/core_mqtt_state.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
7 changes: 5 additions & 2 deletions source/include/core_mqtt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -44,8 +44,11 @@
/**
* @cond DOXYGEN_IGNORE
* The current version of this library.
*
* If MQTT_LIBRARY_VERSION ends with + it represents the version in development
* after the numbered release.
*/
#define MQTT_LIBRARY_VERSION "v2.1.0"
#define MQTT_LIBRARY_VERSION "v2.3.0+"
/** @endcond */

/**
Expand Down
2 changes: 1 addition & 1 deletion source/include/core_mqtt_config_defaults.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion source/include/core_mqtt_serializer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion source/include/core_mqtt_state.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion source/interface/transport_interface.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/include/core_mqtt_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/include/event_callback_stub.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/include/get_time_stub.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/include/mqtt_cbmc_state.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/include/network_interface_stubs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
2 changes: 1 addition & 1 deletion test/cbmc/proofs/MQTT_Disconnect/MQTT_Disconnect_harness.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coreMQTT v2.3.0
* coreMQTT <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
Expand Down
Loading
Loading