build-and-release.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. name: Build all taipy packages and release them
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. target_version:
  6. description: "Package version"
  7. required: true
  8. release_type:
  9. description: "Release type"
  10. required: true
  11. type: choice
  12. options:
  13. - dev
  14. - production
  15. default: "dev"
  16. sub_packages_location:
  17. description: "Dependencies location"
  18. required: true
  19. type: choice
  20. options:
  21. - GitHub
  22. - Pypi
  23. default: "GitHub"
  24. env:
  25. NODE_OPTIONS: --max-old-space-size=4096
  26. permissions:
  27. contents: write
  28. jobs:
  29. fetch-versions:
  30. runs-on: ubuntu-latest
  31. outputs:
  32. common_VERSION: ${{ steps.version-setup.outputs.common_VERSION }}
  33. NEXT_common_VERSION: ${{ steps.version-setup.outputs.NEXT_common_VERSION }}
  34. core_VERSION: ${{ steps.version-setup.outputs.core_VERSION }}
  35. NEXT_core_VERSION: ${{ steps.version-setup.outputs.NEXT_core_VERSION }}
  36. gui_VERSION: ${{ steps.version-setup.outputs.gui_VERSION }}
  37. NEXT_gui_VERSION: ${{ steps.version-setup.outputs.NEXT_gui_VERSION }}
  38. rest_VERSION: ${{ steps.version-setup.outputs.rest_VERSION }}
  39. NEXT_rest_VERSION: ${{ steps.version-setup.outputs.NEXT_rest_VERSION }}
  40. templates_VERSION: ${{ steps.version-setup.outputs.templates_VERSION }}
  41. NEXT_templates_VERSION: ${{ steps.version-setup.outputs.NEXT_templates_VERSION }}
  42. taipy_VERSION: ${{ steps.version-setup.outputs.taipy_VERSION }}
  43. NEXT_taipy_VERSION: ${{ steps.version-setup.outputs.NEXT_taipy_VERSION }}
  44. LATEST_TAIPY_VERSION: ${{ steps.version-setup.outputs.LATEST_TAIPY_VERSION }}
  45. BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
  46. steps:
  47. - uses: actions/checkout@v4
  48. - name: Extract branch name
  49. id: extract_branch
  50. shell: bash
  51. run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
  52. - name: Install mandatory Python packages
  53. run: |
  54. python -m pip install --upgrade pip
  55. pip install requests
  56. - name: Setup Version
  57. id: version-setup
  58. run: |
  59. python tools/release/setup_version.py ALL ${{ github.event.inputs.release_type }} \
  60. ${{ github.event.inputs.target_version }} \
  61. ${{ steps.extract_branch.outputs.branch }} >> $GITHUB_OUTPUT
  62. build-and-release-taipy-packages:
  63. needs: [fetch-versions]
  64. runs-on: ubuntu-latest
  65. timeout-minutes: 20
  66. strategy:
  67. matrix:
  68. package: [common, core, gui, rest, templates]
  69. max-parallel: 1
  70. steps:
  71. - uses: actions/checkout@v4
  72. with:
  73. ssh-key: ${{ secrets.DEPLOY_KEY }}
  74. - uses: actions/setup-python@v5
  75. with:
  76. python-version: 3.9
  77. - uses: actions/setup-node@v4
  78. with:
  79. node-version: '20'
  80. - name: Extract commit hash
  81. id: extract_hash
  82. shell: bash
  83. run: echo "HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
  84. - name: Install mandatory Python packages
  85. run: |
  86. python -m pip install --upgrade pip
  87. pip install requests
  88. - name: Set Build Variables
  89. id: set-variables
  90. shell: bash
  91. run: |
  92. if [ "${{ matrix.package }}" == "common" ]; then
  93. echo "package_version=${{ needs.fetch-versions.outputs.common_VERSION }}" >> $GITHUB_OUTPUT
  94. echo "release_name=${{ needs.fetch-versions.outputs.common_VERSION }}-common" >> $GITHUB_OUTPUT
  95. echo "tar_path=./dist/${{ github.event.repository.name }}-common-${{ needs.fetch-versions.outputs.common_VERSION }}.tar.gz" >> $GITHUB_OUTPUT
  96. elif [ "${{ matrix.package }}" == "core" ]; then
  97. echo "package_version=${{ needs.fetch-versions.outputs.core_VERSION }}" >> $GITHUB_OUTPUT
  98. echo "release_name=${{ needs.fetch-versions.outputs.core_VERSION }}-core" >> $GITHUB_OUTPUT
  99. echo "tar_path=./dist/${{ github.event.repository.name }}-core-${{ needs.fetch-versions.outputs.core_VERSION }}.tar.gz" >> $GITHUB_OUTPUT
  100. elif [ "${{ matrix.package }}" == "gui" ]; then
  101. echo "package_version=${{needs.fetch-versions.outputs.gui_VERSION}}" >> $GITHUB_OUTPUT
  102. echo "release_name=${{ needs.fetch-versions.outputs.gui_VERSION }}-gui" >> $GITHUB_OUTPUT
  103. echo "tar_path=./dist/${{ github.event.repository.name }}-gui-${{ needs.fetch-versions.outputs.gui_VERSION }}.tar.gz" >> $GITHUB_OUTPUT
  104. elif [ "${{ matrix.package }}" == "rest" ]; then
  105. echo "package_version=${{ needs.fetch-versions.outputs.rest_VERSION }}" >> $GITHUB_OUTPUT
  106. echo "release_name=${{ needs.fetch-versions.outputs.rest_VERSION }}-rest" >> $GITHUB_OUTPUT
  107. echo "tar_path=./dist/${{ github.event.repository.name }}-rest-${{ needs.fetch-versions.outputs.rest_VERSION }}.tar.gz" >> $GITHUB_OUTPUT
  108. elif [ "${{ matrix.package }}" == "templates" ]; then
  109. echo "package_version=${{ needs.fetch-versions.outputs.templates_VERSION }}" >> $GITHUB_OUTPUT
  110. echo "release_name=${{ needs.fetch-versions.outputs.templates_VERSION }}-templates" >> $GITHUB_OUTPUT
  111. echo "tar_path=./dist/${{ github.event.repository.name }}-templates-${{ needs.fetch-versions.outputs.templates_VERSION }}.tar.gz" >> $GITHUB_OUTPUT
  112. fi
  113. - name: Update setup.requirements.txt
  114. run: |
  115. python tools/release/update_setup_requirements.py ${{ matrix.package }} \
  116. ${{ needs.fetch-versions.outputs.common_VERSION }} \
  117. ${{ needs.fetch-versions.outputs.core_VERSION }} \
  118. ${{ needs.fetch-versions.outputs.gui_VERSION }} \
  119. ${{ needs.fetch-versions.outputs.rest_VERSION }} \
  120. ${{ needs.fetch-versions.outputs.templates_VERSION }} \
  121. ${{ github.event.inputs.sub_packages_location }} \
  122. ${{ github.repository }}
  123. - name: Install dependencies
  124. run: |
  125. python -m pip install --upgrade pip
  126. pip install build wheel pipenv mypy black isort
  127. - name: Build GUI front-end
  128. if: matrix.package == 'gui'
  129. run: |
  130. pipenv install --dev
  131. pipenv run python tools/gui/generate_pyi.py
  132. python tools/frontend/bundle_build.py gui
  133. - name: Archive the GUI front-end
  134. if: matrix.package == 'gui'
  135. run: |
  136. tar -czf gui-frontend.tar.gz taipy/gui/webapp
  137. - name: Upload front-end archive as an artifact
  138. if: matrix.package == 'gui'
  139. uses: actions/upload-artifact@v4
  140. with:
  141. name: gui-frontend
  142. path: gui-frontend.tar.gz
  143. - name: Build Package Structure
  144. run: |
  145. python tools/release/build_package_structure.py ${{ matrix.package }}
  146. - name: Build package
  147. working-directory: "build_${{ matrix.package }}"
  148. run: |
  149. python -m build
  150. for file in ./dist/*; do mv "$file" "${file//_/-}"; done
  151. - name: Create tag and release ${{ steps.set-variables.outputs.release_name }}
  152. working-directory: "build_${{ matrix.package }}"
  153. run: |
  154. if [ "${{ github.event.inputs.release_type }}" == "dev" ]; then
  155. gh release create ${{ steps.set-variables.outputs.release_name }} ${{ steps.set-variables.outputs.tar_path }} --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title ${{ steps.set-variables.outputs.release_name }} --notes "Dev Release ${{ steps.set-variables.outputs.release_name }}"
  156. else
  157. gh release create ${{ steps.set-variables.outputs.release_name }} ${{ steps.set-variables.outputs.tar_path }} --target ${{ steps.extract_hash.outputs.HASH }} --title ${{ steps.set-variables.outputs.release_name }} --notes "Release ${{ steps.set-variables.outputs.release_name }}"
  158. fi
  159. shell: bash
  160. env:
  161. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  162. build-and-release-taipy:
  163. needs: [build-and-release-taipy-packages, fetch-versions]
  164. runs-on: ubuntu-latest
  165. timeout-minutes: 20
  166. steps:
  167. - uses: actions/checkout@v4
  168. - name: Extract commit hash
  169. id: extract_hash
  170. shell: bash
  171. run: echo "HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
  172. - name: Set Build Variables
  173. id: set-variables
  174. shell: bash
  175. run: |
  176. echo "package_version=${{ needs.fetch-versions.outputs.taipy_VERSION }}" >> $GITHUB_OUTPUT
  177. echo "release_name=${{ needs.fetch-versions.outputs.taipy_VERSION }}" >> $GITHUB_OUTPUT
  178. echo "tar_path=./dist/${{ github.event.repository.name }}-${{ needs.fetch-versions.outputs.taipy_VERSION }}.tar.gz" >> $GITHUB_OUTPUT
  179. - name: Update setup.requirements.txt
  180. run: |
  181. python tools/release/update_setup_requirements.py taipy \
  182. ${{ needs.fetch-versions.outputs.common_VERSION }} \
  183. ${{ needs.fetch-versions.outputs.core_VERSION }} \
  184. ${{ needs.fetch-versions.outputs.gui_VERSION }} \
  185. ${{ needs.fetch-versions.outputs.rest_VERSION }} \
  186. ${{ needs.fetch-versions.outputs.templates_VERSION }} \
  187. ${{ github.event.inputs.sub_packages_location }} \
  188. ${{ github.repository }}
  189. - name: Install dependencies
  190. run: |
  191. python -m pip install --upgrade pip
  192. pip install build wheel
  193. - uses: actions/download-artifact@v4
  194. with:
  195. name: gui-frontend
  196. path: .
  197. - name: Retrieve the GUI front-end
  198. run: tar -xzf gui-frontend.tar.gz
  199. - name: Build taipy front-end
  200. run: |
  201. python tools/frontend/bundle_build.py taipy
  202. - name: Build taipy Package Structure
  203. run: |
  204. python tools/release/build_package_structure.py taipy
  205. - name: Build taipy package
  206. working-directory: "build_taipy"
  207. run: |
  208. python -m build
  209. - name: Create tag and release Taipy
  210. working-directory: "build_taipy"
  211. run: |
  212. if [ "${{ github.event.inputs.release_type }}" == "dev" ]; then
  213. gh release create ${{ steps.set-variables.outputs.release_name }} ${{ steps.set-variables.outputs.tar_path }} --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title ${{ steps.set-variables.outputs.release_name }} --notes "Dev Release ${{ steps.set-variables.outputs.release_name }}"
  214. else
  215. gh release create ${{ steps.set-variables.outputs.release_name }} ${{ steps.set-variables.outputs.tar_path }} --target ${{ steps.extract_hash.outputs.HASH }} --title ${{ steps.set-variables.outputs.release_name }} --notes "Release ${{ steps.set-variables.outputs.release_name }}"
  216. fi
  217. shell: bash
  218. env:
  219. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  220. - name: Download packages
  221. working-directory: "build_taipy"
  222. run: |
  223. gh release download ${{ needs.fetch-versions.outputs.common_VERSION }}-common --skip-existing --dir dist
  224. gh release download ${{ needs.fetch-versions.outputs.core_VERSION }}-core --skip-existing --dir dist
  225. gh release download ${{ needs.fetch-versions.outputs.gui_VERSION }}-gui --skip-existing --dir dist
  226. gh release download ${{ needs.fetch-versions.outputs.rest_VERSION }}-rest --skip-existing --dir dist
  227. gh release download ${{ needs.fetch-versions.outputs.templates_VERSION }}-templates --skip-existing --dir dist
  228. env:
  229. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  230. - name: Bundle all packages in main release tag
  231. working-directory: "build_taipy"
  232. run: |
  233. find dist -type f -print0 | xargs -r0 gh release upload ${{ needs.fetch-versions.outputs.taipy_VERSION }} --clobber
  234. env:
  235. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  236. - name: Ensure the latest 'taipy' production release is marked as *latest*
  237. if: github.event.inputs.release_type == 'dev'
  238. run: |
  239. gh release edit ${{ needs.fetch-versions.outputs.LATEST_TAIPY_VERSION }} --latest
  240. shell: bash
  241. env:
  242. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}