Release automation #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release automation | |
on: | |
workflow_dispatch: | |
inputs: | |
commit_id: | |
description: 'Commit ID to tag and create a release for' | |
required: true | |
version_number: | |
description: 'Release Version Number (Eg, v1.0.0)' | |
required: true | |
jobs: | |
tag-commit: | |
name: Tag commit | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.commit_id }} | |
- name: Configure git identity | |
env: | |
ACTOR: ${{ github.actor }} | |
run: | | |
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 | |
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 }} | |
source_folder_list: "source test" | |
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,/^ \* FreeRTOS\+TCP/s/^ \* FreeRTOS\+TCP.*/ \* FreeRTOS\+TCP $VERSION_NUMBER/g" {} +' | |
git add . | |
git commit -m '[AUTO][RELEASE]: Update version number in source files' | |
git push -u origin "$VERSION_NUMBER" | |
- name: Generate SBOM | |
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main | |
with: | |
repo_path: ./ | |
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 "$VERSION_NUMBER" | |
- name: Tag Commit and Push to remote | |
env: | |
VERSION_NUMBER: ${{ github.event.inputs.version_number }} | |
run: | | |
git tag "$VERSION_NUMBER" -a -m "FreeRTOS-Plus-TCP 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 "$VERSION_NUMBER" | |
git remote update | |
git checkout tags/"$VERSION_NUMBER" | |
git diff "$COMMIT_ID" tags/"$VERSION_NUMBER" | |
create-zip: | |
needs: tag-commit | |
name: Create ZIP and verify package for release asset. | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install ZIP tools | |
run: sudo apt-get install zip unzip | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.version_number }} | |
path: FreeRTOS-Plus-TCP | |
submodules: recursive | |
- name: Checkout disabled submodules | |
run: | | |
cd FreeRTOS-Plus-TCP | |
git submodule update --init --checkout --recursive | |
- name: Create ZIP | |
env: | |
VERSION_NUMBER: ${{ github.event.inputs.version_number }} | |
run: | | |
zip -r FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip FreeRTOS-Plus-TCP -x "*.git*" | |
ls ./ | |
- name: Validate created ZIP | |
env: | |
VERSION_NUMBER: ${{ github.event.inputs.version_number }} | |
run: | | |
mkdir zip-check | |
mv FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip zip-check | |
cd zip-check | |
unzip FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip -d FreeRTOS-Plus-TCP-"$VERSION_NUMBER" | |
ls FreeRTOS-Plus-TCP-"$VERSION_NUMBER" | |
diff -r -x "*.git*" FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP/ ../FreeRTOS-Plus-TCP/ | |
cd ../ | |
- name: Build | |
env: | |
VERSION_NUMBER: ${{ github.event.inputs.version_number }} | |
run: | | |
cd zip-check/FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP | |
sudo apt-get install -y lcov | |
sudo apt-get install unifdef | |
cmake -S test/unit-test -B test/unit-test/build/ | |
make -C test/unit-test/build/ all | |
- name: Test | |
env: | |
VERSION_NUMBER: ${{ github.event.inputs.version_number }} | |
run: | | |
cd zip-check/FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP | |
pushd test/unit-test/build/ | |
ctest -E system --output-on-failure | |
popd | |
make -C test/unit-test/build/ coverage | |
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info | |
cd .. | |
- name: Create artifact of ZIP | |
uses: actions/upload-artifact@v4 | |
with: | |
name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip | |
path: zip-check/FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip | |
deploy-doxygen: | |
needs: tag-commit | |
name: Deploy doxygen documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Doxygen generation | |
uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main | |
with: | |
ref: ${{ github.event.inputs.version_number }} | |
add_release: "true" | |
create-release: | |
needs: | |
- create-zip | |
- deploy-doxygen | |
name: Create Release and Upload Release Asset | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
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 FreeRTOS-Plus-TCP Library. | |
draft: false | |
prerelease: false | |
- name: Download ZIP artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip | |
- 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: ./FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip | |
asset_name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip | |
asset_content_type: application/zip | |
cleanup: | |
needs: | |
- create-release | |
name: Cleanup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Delete branch created for Tag by SBOM generator | |
env: | |
VERSION_NUMBER: ${{ github.event.inputs.version_number }} | |
run: | | |
# Delete the branch created for Tag by SBOM generator | |
git push -u origin --delete refs/heads/"$VERSION_NUMBER" |