Skip to content

Commit 2f59841

Browse files
Add release.yml
1 parent 7d0e4c0 commit 2f59841

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

.github/workflows/release.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Release automation
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
commit_id:
7+
description: 'Commit ID to tag and create a release for'
8+
required: true
9+
version_number:
10+
description: 'Release Version Number (Eg, v1.0.0)'
11+
required: true
12+
13+
jobs:
14+
tag-commit:
15+
name: Tag commit
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.event.inputs.commit_id }}
22+
- name: Configure git identity
23+
run: |
24+
git config --global user.name ${{ github.actor }}
25+
git config --global user.email ${{ github.actor }}@users.noreply.github.com
26+
- name: create a new branch that references commit id
27+
run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
28+
- name: Generate SBOM
29+
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
30+
with:
31+
repo_path: ./
32+
source_path: ./source
33+
- name: commit SBOM file
34+
run: |
35+
git add .
36+
git commit -m 'Update SBOM'
37+
git push -u origin ${{ github.event.inputs.version_number }}
38+
- name: Tag Commit and Push to remote
39+
run: |
40+
git tag ${{ github.event.inputs.version_number }} -a -m "AWS IoT Core MQTT File Streams ${{ github.event.inputs.version_number }}"
41+
git push origin --tags
42+
- name: Verify tag on remote
43+
run: |
44+
git tag -d ${{ github.event.inputs.version_number }}
45+
git remote update
46+
git checkout tags/${{ github.event.inputs.version_number }}
47+
git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
48+
create-zip:
49+
needs: tag-commit
50+
name: Create ZIP and verify package for release asset.
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Install ZIP tools
54+
run: sudo apt-get install zip unzip
55+
- name: Checkout code
56+
uses: actions/checkout@v3
57+
with:
58+
ref: ${{ github.event.inputs.commit_id }}
59+
path: aws-iot-core-mqtt-file-streams-embedded-c
60+
submodules: recursive
61+
- name: Checkout disabled submodules
62+
run: |
63+
cd aws-iot-core-mqtt-file-streams-embedded-c
64+
git submodule update --init --checkout --recursive
65+
- name: Create ZIP
66+
run: |
67+
zip -r aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip aws-iot-core-mqtt-file-streams-embedded-c -x "*.git*"
68+
ls ./
69+
- name: Validate created ZIP
70+
run: |
71+
mkdir zip-check
72+
mv aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip zip-check
73+
cd zip-check
74+
unzip aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip -d aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}
75+
ls aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}
76+
diff -r -x "*.git*" aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}/aws-iot-core-mqtt-file-streams-embedded-c/ ../aws-iot-core-mqtt-file-streams-embedded-c/
77+
cd ../
78+
- name: Build
79+
run: |
80+
cd zip-check/aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}/aws-iot-core-mqtt-file-streams-embedded-c
81+
sudo apt-get install -y lcov
82+
cmake -S test -B build/ \
83+
-G "Unix Makefiles" \
84+
-DCMAKE_BUILD_TYPE=Debug \
85+
-DBUILD_CLONE_SUBMODULES=ON \
86+
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror'
87+
make -C build/ all
88+
- name: Test
89+
run: |
90+
cd zip-check/aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}/aws-iot-core-mqtt-file-streams-embedded-c/build/
91+
ctest -E system --output-on-failure
92+
cd ..
93+
- name: Create artifact of ZIP
94+
uses: actions/upload-artifact@v2
95+
with:
96+
name: aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip
97+
path: zip-check/aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip
98+
deploy-doxygen:
99+
needs: tag-commit
100+
name: Deploy doxygen documentation
101+
runs-on: ubuntu-latest
102+
steps:
103+
- name: Doxygen generation
104+
uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main
105+
with:
106+
ref: ${{ github.event.inputs.version_number }}
107+
add_release: "true"
108+
create-release:
109+
needs:
110+
- create-zip
111+
- deploy-doxygen
112+
name: Create Release and Upload Release Asset
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Create Release
116+
id: create_release
117+
uses: actions/create-release@v1
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
with:
121+
tag_name: ${{ github.event.inputs.version_number }}
122+
release_name: ${{ github.event.inputs.version_number }}
123+
body: Release ${{ github.event.inputs.version_number }} of AWS IoT Core MQTT File Streams Embedded C.
124+
draft: false
125+
prerelease: false
126+
- name: Download ZIP artifact
127+
uses: actions/download-artifact@v2
128+
with:
129+
name: aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip
130+
- name: Upload Release Asset
131+
id: upload-release-asset
132+
uses: actions/upload-release-asset@v1
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
with:
136+
upload_url: ${{ steps.create_release.outputs.upload_url }}
137+
asset_path: ./aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip
138+
asset_name: aws-iot-core-mqtt-file-streams-embedded-c-${{ github.event.inputs.version_number }}.zip
139+
asset_content_type: application/zip

0 commit comments

Comments
 (0)