|
1 |
| -name: Build and release one taipy sub-package |
| 1 | +name: Build one taipy sub-package release |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_dispatch:
|
5 | 5 | inputs:
|
6 |
| - internal_dep_on_pypi: |
7 |
| - description: "Point taipy internal dependencies to Pypi? If false it will point to the github .tar.gz release file" |
8 |
| - default: "false" |
9 |
| - required: true |
10 |
| - release_type: |
11 |
| - description: "The type of release to be made (dev or production)" |
12 |
| - default: "dev" |
| 6 | + target_package: |
| 7 | + description: "Package name" |
13 | 8 | required: true
|
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - gui |
| 12 | + - common |
| 13 | + - core |
| 14 | + - rest |
| 15 | + - templates |
| 16 | + - taipy |
14 | 17 | target_version:
|
15 |
| - description: "The version of the package to be released" |
| 18 | + description: "Package version" |
16 | 19 | required: true
|
17 |
| - target_package: |
18 |
| - description: "The package to be released (gui, common, core, rest, templates, taipy)" |
| 20 | + release_type: |
| 21 | + description: "Release type" |
19 | 22 | required: true
|
| 23 | + type: choice |
| 24 | + options: |
| 25 | + - dev |
| 26 | + - production |
| 27 | + default: "dev" |
| 28 | + sub_packages_location: |
| 29 | + description: "Dependencies location" |
| 30 | + required: true |
| 31 | + type: choice |
| 32 | + options: |
| 33 | + - GitHub |
| 34 | + - Pypi |
| 35 | + default: "GitHub" |
20 | 36 |
|
21 | 37 | env:
|
22 | 38 | NODE_OPTIONS: --max-old-space-size=4096
|
23 | 39 |
|
24 | 40 | permissions:
|
25 | 41 | contents: write
|
| 42 | + pull-requests: write |
26 | 43 |
|
27 | 44 | jobs:
|
28 |
| - fetch-versions: |
| 45 | + setup-versions: |
29 | 46 | runs-on: ubuntu-latest
|
30 | 47 | outputs:
|
| 48 | + branch: ${{ steps.version-setup.outputs.branch }} |
31 | 49 | common_VERSION: ${{ steps.version-setup.outputs.common_VERSION }}
|
32 | 50 | core_VERSION: ${{ steps.version-setup.outputs.core_VERSION }}
|
33 | 51 | gui_VERSION: ${{ steps.version-setup.outputs.gui_VERSION }}
|
34 | 52 | rest_VERSION: ${{ steps.version-setup.outputs.rest_VERSION }}
|
35 | 53 | templates_VERSION: ${{ steps.version-setup.outputs.templates_VERSION }}
|
36 | 54 | taipy_VERSION: ${{ steps.version-setup.outputs.taipy_VERSION }}
|
| 55 | + LATEST_TAIPY_VERSION: ${{ steps.version-setup.outputs.LATEST_TAIPY_VERSION }} |
37 | 56 | steps:
|
38 | 57 | - uses: actions/checkout@v4
|
39 |
| - - name: Extract branch name |
40 |
| - shell: bash |
41 |
| - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT |
42 |
| - id: extract_branch |
43 | 58 |
|
44 |
| - - name: Setup Version |
| 59 | + - name: Validate target version |
| 60 | + run: | |
| 61 | + version="${{ github.event.inputs.target_version }}" |
| 62 | + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 63 | + echo "❌ Invalid version format: '$version' - <M>.<m>.<patch> is mandatory." |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + echo "✅ Valid target version: $version" |
| 67 | +
|
| 68 | + - name: Install mandatory Python packages |
| 69 | + run: | |
| 70 | + python -m pip install --upgrade pip |
| 71 | + pip install requests |
| 72 | +
|
| 73 | + - name: Setup versions |
45 | 74 | id: version-setup
|
46 | 75 | run: |
|
47 |
| - python tools/release/fetch_latest_versions.py \ |
48 |
| - ${{ github.event.inputs.release_type }} \ |
49 |
| - ${{ github.event.inputs.internal_dep_on_pypi }} \ |
50 |
| - ${{ github.event.inputs.target_version }} \ |
51 |
| - ${{ github.event.inputs.target_package }} >> $GITHUB_OUTPUT |
| 76 | + python tools/release/setup_versions.py \ |
| 77 | + ${{ github.event.inputs.target_package }} \ |
| 78 | + -v ${{ github.event.inputs.target_version }} \ |
| 79 | + -t ${{ github.event.inputs.release_type }} \ |
| 80 | + -r ${{ github.repository }} >>$GITHUB_OUTPUT |
| 81 | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >>$GITHUB_OUTPUT |
52 | 82 |
|
53 |
| - build-and-release-package: |
54 |
| - needs: [fetch-versions] |
| 83 | + build-package-release: |
| 84 | + needs: setup-versions |
55 | 85 | timeout-minutes: 20
|
56 | 86 | runs-on: ubuntu-latest
|
57 | 87 | steps:
|
58 | 88 | - uses: actions/checkout@v4
|
59 |
| - with: |
60 |
| - ssh-key: ${{secrets.DEPLOY_KEY}} |
61 | 89 | - uses: actions/setup-python@v5
|
62 | 90 | with:
|
63 | 91 | python-version: 3.9
|
64 | 92 | - uses: actions/setup-node@v4
|
65 | 93 | with:
|
66 |
| - node-version: '20' |
| 94 | + node-version: "20" |
67 | 95 |
|
68 | 96 | - name: Extract commit hash
|
| 97 | + id: extract_hash |
69 | 98 | shell: bash
|
70 | 99 | run: echo "HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
71 |
| - id: extract_hash |
72 | 100 |
|
73 |
| - - name: Set Build Variables |
74 |
| - id: set-variables |
| 101 | + - name: Install mandatory Python packages |
| 102 | + run: | |
| 103 | + python -m pip install --upgrade pip |
| 104 | + pip install requests |
| 105 | +
|
| 106 | + - name: Update setup.requirements.txt |
| 107 | + run: | |
| 108 | + python tools/release/update_setup_requirements.py ${{ github.event.inputs.target_package }} \ |
| 109 | + ${{ needs.setup-versions.outputs.common_VERSION }} \ |
| 110 | + ${{ needs.setup-versions.outputs.core_VERSION }} \ |
| 111 | + ${{ needs.setup-versions.outputs.gui_VERSION }} \ |
| 112 | + ${{ needs.setup-versions.outputs.rest_VERSION }} \ |
| 113 | + ${{ needs.setup-versions.outputs.templates_VERSION }} \ |
| 114 | + -deps ${{ github.event.inputs.sub_packages_location }} \ |
| 115 | + -r ${{ github.repository }} |
| 116 | +
|
| 117 | + - name: Set package version for ${{ github.event.inputs.target_package }} ${{ github.event.inputs.target_version }} |
| 118 | + id: package-version |
| 119 | + shell: bash |
75 | 120 | run: |
|
76 | 121 | if [ "${{ github.event.inputs.target_package }}" == "common" ]; then
|
77 |
| - echo "package_version=${{needs.fetch-versions.outputs.common_VERSION}}" >> $GITHUB_OUTPUT |
78 |
| - echo "package_dir=./taipy/common" >> $GITHUB_OUTPUT |
79 |
| - echo "release_name=${{needs.fetch-versions.outputs.common_VERSION}}-common" >> $GITHUB_OUTPUT |
80 |
| - echo "tar_path=./dist/${{ github.event.repository.name }}-common-${{needs.fetch-versions.outputs.common_VERSION}}.tar.gz" >> $GITHUB_OUTPUT |
| 122 | + echo "version=${{ needs.setup-versions.outputs.common_VERSION }}" >> $GITHUB_OUTPUT |
81 | 123 | elif [ "${{ github.event.inputs.target_package }}" == "core" ]; then
|
82 |
| - echo "package_version=${{needs.fetch-versions.outputs.core_VERSION}}" >> $GITHUB_OUTPUT |
83 |
| - echo "package_dir=./taipy/core" >> $GITHUB_OUTPUT |
84 |
| - echo "release_name=${{needs.fetch-versions.outputs.core_VERSION}}-core" >> $GITHUB_OUTPUT |
85 |
| - echo "tar_path=./dist/${{ github.event.repository.name }}-core-${{needs.fetch-versions.outputs.core_VERSION}}.tar.gz" >> $GITHUB_OUTPUT |
| 124 | + echo "version=${{ needs.setup-versions.outputs.core_VERSION }}" >> $GITHUB_OUTPUT |
86 | 125 | elif [ "${{ github.event.inputs.target_package }}" == "gui" ]; then
|
87 |
| - echo "package_version=${{needs.fetch-versions.outputs.gui_VERSION}}" >> $GITHUB_OUTPUT |
88 |
| - echo "package_dir=./taipy/gui" >> $GITHUB_OUTPUT |
89 |
| - echo "release_name=${{needs.fetch-versions.outputs.gui_VERSION}}-gui" >> $GITHUB_OUTPUT |
90 |
| - echo "tar_path=./dist/${{ github.event.repository.name }}-gui-${{needs.fetch-versions.outputs.gui_VERSION}}.tar.gz" >> $GITHUB_OUTPUT |
| 126 | + echo "version=${{ needs.setup-versions.outputs.gui_VERSION }}" >> $GITHUB_OUTPUT |
91 | 127 | elif [ "${{ github.event.inputs.target_package }}" == "rest" ]; then
|
92 |
| - echo "package_version=${{needs.fetch-versions.outputs.rest_VERSION}}" >> $GITHUB_OUTPUT |
93 |
| - echo "package_dir=./taipy/rest" >> $GITHUB_OUTPUT |
94 |
| - echo "release_name=${{needs.fetch-versions.outputs.rest_VERSION}}-rest" >> $GITHUB_OUTPUT |
95 |
| - echo "tar_path=./dist/${{ github.event.repository.name }}-rest-${{needs.fetch-versions.outputs.rest_VERSION}}.tar.gz" >> $GITHUB_OUTPUT |
| 128 | + echo "version=${{ needs.setup-versions.outputs.rest_VERSION }}" >> $GITHUB_OUTPUT |
96 | 129 | elif [ "${{ github.event.inputs.target_package }}" == "templates" ]; then
|
97 |
| - echo "package_version=${{needs.fetch-versions.outputs.templates_VERSION}}" >> $GITHUB_OUTPUT |
98 |
| - echo "package_dir=./taipy/templates" >> $GITHUB_OUTPUT |
99 |
| - echo "release_name=${{needs.fetch-versions.outputs.templates_VERSION}}-templates" >> $GITHUB_OUTPUT |
100 |
| - echo "tar_path=./dist/${{ github.event.repository.name }}-templates-${{needs.fetch-versions.outputs.templates_VERSION}}.tar.gz" >> $GITHUB_OUTPUT |
| 130 | + echo "version=${{ needs.setup-versions.outputs.templates_VERSION }}" >> $GITHUB_OUTPUT |
| 131 | + elif [ "${{ github.event.inputs.target_package }}" == "taipy" ]; then |
| 132 | + echo "version=${{ needs.setup-versions.outputs.taipy_VERSION }}" >> $GITHUB_OUTPUT |
101 | 133 | fi
|
102 |
| - shell: bash |
103 |
| - |
104 |
| - - name: Update setup.requirements.txt |
105 |
| - run: | |
106 |
| - python tools/release/update_setup_requirements.py taipy-${{ github.event.inputs.target_package }} \ |
107 |
| - ${{needs.fetch-versions.outputs.common_VERSION}} \ |
108 |
| - ${{needs.fetch-versions.outputs.core_VERSION}} \ |
109 |
| - ${{needs.fetch-versions.outputs.gui_VERSION}} \ |
110 |
| - ${{needs.fetch-versions.outputs.rest_VERSION}} \ |
111 |
| - ${{needs.fetch-versions.outputs.templates_VERSION}} \ |
112 |
| - ${{ github.event.inputs.internal_dep_on_pypi }} |
113 |
| -
|
114 |
| - - name: Copy tools |
115 |
| - run: | |
116 |
| - cp -r tools ${{ steps.set-variables.outputs.package_dir }} |
117 | 134 |
|
118 | 135 | - name: Install dependencies
|
119 | 136 | run: |
|
120 | 137 | python -m pip install --upgrade pip
|
121 | 138 | pip install build wheel pipenv mypy black isort
|
122 | 139 |
|
123 | 140 | - name: Install GUI dependencies
|
124 |
| - if: github.event.inputs.target_package == 'gui' |
| 141 | + if: ${{ github.event.inputs.target_package == 'gui' || github.event.inputs.target_package == 'taipy' }} |
125 | 142 | run: |
|
126 | 143 | pipenv install --dev
|
127 | 144 |
|
128 | 145 | - name: Generate GUI pyi file
|
129 |
| - if: github.event.inputs.target_package == 'gui' |
| 146 | + if: ${{ github.event.inputs.target_package == 'gui' }} |
130 | 147 | run: |
|
131 | 148 | pipenv run python tools/gui/generate_pyi.py
|
132 | 149 |
|
133 |
| - - name: Build frontends |
134 |
| - if: github.event.inputs.target_package == 'gui' |
| 150 | + - name: Build Taipy GUI front-end |
| 151 | + if: ${{ github.event.inputs.target_package == 'gui' || github.event.inputs.target_package == 'taipy' }} |
135 | 152 | run: |
|
136 |
| - python tools/frontend/bundle_build.py |
| 153 | + python tools/frontend/bundle_build.py gui |
137 | 154 |
|
138 |
| - - name: Copy files from tools |
| 155 | + - name: Build Taipy front-end |
| 156 | + if: ${{ github.event.inputs.target_package == 'taipy' }} |
139 | 157 | run: |
|
140 |
| - cp -r tools/packages/taipy-${{ github.event.inputs.target_package }}/. ${{ steps.set-variables.outputs.package_dir }} |
| 158 | + python tools/frontend/bundle_build.py taipy |
141 | 159 |
|
142 | 160 | - name: Build Package Structure
|
143 |
| - working-directory: ${{ steps.set-variables.outputs.package_dir }} |
144 | 161 | run: |
|
145 |
| - python tools/release/build_package_structure.py ${{ github.event.inputs.target_package }} |
146 |
| -
|
147 |
| - - name: Copy Taipy Logger |
148 |
| - if: github.event.inputs.target_package == 'common' |
149 |
| - run: | |
150 |
| - cp -r taipy/logger/. ${{ steps.set-variables.outputs.package_dir }}/taipy/logger |
151 |
| -
|
152 |
| - - name: Copy _cli folder |
153 |
| - run: | |
154 |
| - cp -r taipy/_cli/. ${{ steps.set-variables.outputs.package_dir }}/taipy/_cli |
| 162 | + python tools/release/build_package_structure.py ${{ github.event.inputs.target_package }} ${{ steps.package-version.outputs.version }} |
155 | 163 |
|
156 | 164 | - name: Build package
|
157 |
| - working-directory: ${{ steps.set-variables.outputs.package_dir }} |
| 165 | + working-directory: "build_${{ github.event.inputs.target_package }}" |
158 | 166 | run: |
|
159 | 167 | python -m build
|
160 |
| -
|
161 |
| - - name: Rename files |
162 |
| - working-directory: ${{ steps.set-variables.outputs.package_dir }} |
163 |
| - run: | |
164 |
| - for file in ./dist/*; do mv "$file" "${file//_/-}"; done |
165 |
| -
|
| 168 | + if compgen -G "./dist/*_*" > /dev/null; then |
| 169 | + for file in ./dist/*_*; do mv "$file" "${file//_/-}"; done |
| 170 | + fi |
| 171 | + |
166 | 172 | - name: Create tag and release
|
167 |
| - working-directory: ${{ steps.set-variables.outputs.package_dir }} |
| 173 | + working-directory: "build_${{ github.event.inputs.target_package }}" |
168 | 174 | run: |
|
169 |
| - if [ "${{ github.event.inputs.release_type }}" == "dev" ]; then |
170 |
| - 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 "Release Draft ${{ steps.set-variables.outputs.release_name }}" |
171 |
| - else |
172 |
| - 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 }}" |
173 |
| - fi |
| 175 | + package_suffix="" |
| 176 | + if [ "${{ github.event.inputs.target_package }}" != "taipy" ]; then |
| 177 | + package_suffix="-${{ github.event.inputs.target_package }}" |
| 178 | + fi |
| 179 | + release_name="${{ steps.package-version.outputs.version }}$package_suffix" |
| 180 | + tar_path="./dist/taipy$package_suffix-${{ steps.package-version.outputs.version }}.tar.gz" |
| 181 | + if [ "${{ github.event.inputs.release_type }}" == "dev" ]; then |
| 182 | + gh release create $release_name $tar_path --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title $release_name --notes "Dev Release $release_name" |
| 183 | + else |
| 184 | + gh release create $release_name $tar_path --target ${{ steps.extract_hash.outputs.HASH }} --title $release_name --notes "Release $release_name" |
| 185 | + fi |
174 | 186 | shell: bash
|
175 | 187 | env:
|
176 | 188 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
177 | 189 |
|
178 |
| - - name: Ensure Taipy release is marked as latest |
| 190 | + - name: Bump patch version |
| 191 | + if: ${{ github.event.inputs.release_type == 'production' }} |
179 | 192 | run: |
|
180 |
| - gh release edit ${{needs.fetch-versions.outputs.taipy_VERSION}} --latest |
| 193 | + python tools/release/bump_patch_version.py ${{ github.event.inputs.target_package }} |
| 194 | +
|
| 195 | + - uses: stefanzweifel/git-auto-commit-action@v5 |
| 196 | + if: ${{ github.event.inputs.release_type == 'production' }} |
| 197 | + with: |
| 198 | + branch: "devops/bump-patch-version-for-${{ github.event.inputs.target_package }}-${{ github.run_id }}" |
| 199 | + create_branch: "true" |
| 200 | + file_pattern: "**/version.json" |
| 201 | + commit_message: Bump patch versions for ${{ github.event.inputs.target_package }} |
| 202 | + |
| 203 | + - name: Create pull request |
| 204 | + if: ${{ github.event.inputs.release_type == 'production' }} |
| 205 | + run: gh pr create -B "${{ needs.setup-versions.outputs.branch }}" -H "devops/bump-patch-version-for-${{ github.event.inputs.target_package }}-${{ github.run_id }}" --title "Bump patch version" --body "Created by GitHub action build-and-release-single-package" |
| 206 | + env: |
| 207 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 208 | + |
| 209 | + # Ensure the latest 'taipy' production release, if there is one, is marked as *latest* no matter what |
| 210 | + - name: Force latest 'taipy' production release |
| 211 | + run: | |
| 212 | + if [ "${{ needs.setup-versions.outputs.LATEST_TAIPY_VERSION }}" != "0.0.0" ]; then |
| 213 | + gh release edit ${{ needs.setup-versions.outputs.LATEST_TAIPY_VERSION }} --latest |
| 214 | + fi |
181 | 215 | shell: bash
|
182 | 216 | env:
|
183 | 217 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
0 commit comments