Skip to content

Release Automation

Release Automation #1

name: Release Automation
on:
workflow_dispatch:
inputs:
commit_id:
description: 'Commit ID to tag and push to remote'
required: true
version_number:
description: 'Tag Version Number (Eg, 202012.00)'
required: true
jobs:
tag-commit:
name: Tag commit
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_id }}
- name: Configure git identity
run: |
git config --global user.name "Release Workflow"
- name: Tag Commit and Push to remote
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
git tag "$VERSION_NUMBER" -a -m "AWS IoT Device SDK for Embedded C version $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-20.04
steps:
- name: Install ZIP tools
run: sudo apt-get install zip unzip
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_id }}
path: aws-iot-device-sdk-embedded-C
submodules: recursive
- name: Checkout disabled submodules
run: |
cd aws-iot-device-sdk-embedded-C
git submodule update --init --checkout --recursive
- name: Create ZIP
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
zip -r aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER".zip aws-iot-device-sdk-embedded-C -x "*.git*"
ls ./
- name: Validate created ZIP
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
mkdir zip-check
mv aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER".zip zip-check
cd zip-check
unzip aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER".zip -d aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER"
ls aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER"
diff -r -x "*.git*" aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER"/aws-iot-device-sdk-embedded-C/ ../aws-iot-device-sdk-embedded-C/
cd ../
- name : Build Check Demos
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
sudo apt-get install -y libmosquitto-dev
cd zip-check/aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER"/aws-iot-device-sdk-embedded-C/
cmake -S . -B build/ \
-G "Unix Makefiles" \
-DBUILD_DEMOS=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS='-Wall -Wextra -Werror' \
-DAWS_IOT_ENDPOINT="aws-iot-endpoint" \
-DBROKER_ENDPOINT="broker-endpoint" \
-DCLIENT_CERT_PATH="cert/path" \
-DROOT_CA_CERT_PATH="cert/path" \
-DCLIENT_PRIVATE_KEY_PATH="key/path" \
-DCLIENT_IDENTIFIER="ci-identifier" \
-DTHING_NAME="thing-name" \
-DS3_PRESIGNED_GET_URL="get-url" \
-DS3_PRESIGNED_PUT_URL="put-url" \
-DCLAIM_CERT_PATH="cert/path" \
-DCLAIM_PRIVATE_KEY_PATH="key/path" \
-DPROVISIONING_TEMPLATE_NAME="template-name" \
-DDEVICE_SERIAL_NUMBER="00000" \
-DCSR_SUBJECT_NAME="CN=Fleet Provisioning Demo" \
-DGREENGRASS_ADDRESS="greengrass-address"
make -C build/ help | grep demo | tr -d '. ' | xargs make -C build/ -j8
make -C demos/jobs/jobs_demo_mosquitto -j8
- name : Build Check Tests
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
cd zip-check/aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER"/aws-iot-device-sdk-embedded-C/
rm -rf ./build
cmake -S . -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTS=1 \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -Wno-unused-parameter' \
-DAWS_IOT_ENDPOINT="aws-iot-endpoint" \
-DBROKER_ENDPOINT="broker-endpoint" \
-DCLIENT_CERT_PATH="cert/path" \
-DROOT_CA_CERT_PATH="cert/path" \
-DCLIENT_PRIVATE_KEY_PATH="key/path" \
-DCLIENT_IDENTIFIER="ci-identifier"
make -C build/ all -j8
- name: Run Unit Tests
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
cd zip-check/aws-iot-device-sdk-embedded-C-"$VERSION_NUMBER"/aws-iot-device-sdk-embedded-C/build/
ctest -E system --output-on-failure
cd ..
- name: Create artifact of ZIP
uses: actions/upload-artifact@v4
with:
name: aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip
path: zip-check/aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip
deploy-docs:
needs: tag-commit
name: Deploy doxygen docs
runs-on: ubuntu-20.04
steps:
- name: Deploy doxygen for release tag
uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main
with:
ref: ${{ github.event.inputs.version_number }}
add_release: "true"
generate_command: |
git submodule update --init --depth 1
if python3 tools/doxygen/generate_docs.py --root . ; then
find * -type d -wholename '*/doxygen/output' -exec mkdir -p html/{} \; -exec mv {}/html html/{} \;
cat << END > html/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url='docs/doxygen/output/html'" />
</head>
<body>
<p><a href="docs/doxygen/output/html">Click here if page does not redirect.</a></p>
</body>
</html>
END
else
exit 1
fi
output_dir: html
create-release:
needs:
- create-zip
- deploy-docs
name: Create Release and Upload Release Asset
runs-on: ubuntu-20.04
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 version ${{ github.event.inputs.version_number }} of the AWS IoT Device SDK for Embedded C.
draft: false
prerelease: false
- name: Download ZIP artifact
uses: actions/download-artifact@v4
with:
name: aws-iot-device-sdk-embedded-C-${{ 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: ./aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip
asset_name: aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip
asset_content_type: application/zip