release.yml 5.1 KB

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