소스 검색

Merge pull request #258 from Avaiga/feature/update-release-process

Update release process
dinhlongnguyen 1 년 전
부모
커밋
e9035f5ae5
5개의 변경된 파일142개의 추가작업 그리고 267개의 파일을 삭제
  1. 0 118
      .github/workflows/publish-dev.yml
  2. 23 45
      .github/workflows/publish.yml
  3. 79 91
      .github/workflows/release-dev.yml
  4. 25 13
      .github/workflows/release.yml
  5. 15 0
      tools/modify_readme.py

+ 0 - 118
.github/workflows/publish-dev.yml

@@ -1,118 +0,0 @@
-name: Publish pre-release on Pypi
-
-on:
-  workflow_dispatch:
-    inputs:
-      version:
-        description: "The Pypi dev package version to create (ex: 2.3.0.dev0)"
-        required: true
-
-jobs:
-  verify-dev-package:
-    timeout-minutes: 20
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v3
-      - uses: actions/setup-python@v4
-        with:
-          python-version: 3.8
-
-      - name: Extract Github Tag Version
-        id: vars
-        run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
-      - name: Ensure package version has 'dev' suffix
-        run: |
-          echo """
-          import json, sys, os
-          SUFFIX = 'dev'
-          with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
-              version_o = json.load(version_file)
-          version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
-          if vext := version_o.get(\"ext\"):
-              version = f'{version}.{vext}'
-          if SUFFIX not in version:
-              raise ValueError(f\"version {version} does not contain suffix {SUFFIX}\")
-          """ > /tmp/check1.py
-          python /tmp/check1.py
-
-      - name: Ensure package version is properly set
-        run: |
-          echo """
-          import json, sys, os
-          with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
-            version_o = json.load(version_file)
-          version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
-          if vext := version_o.get(\"ext\"):
-            version = f'{version}.{vext}'
-          if version != sys.argv[1]:
-            raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
-          if sys.argv[1] != sys.argv[2]:
-            raise ValueError(f\"Invalid tag version {sys.argv[2]} with package version {sys.argv[1]}\")
-          """ > /tmp/check2.py
-          python /tmp/check2.py "${{ github.event.inputs.version }}" "${{ steps.vars.outputs.tag }}"
-
-      - name: Download assets from github release tag
-        run: |
-          gh release download ${{ github.event.inputs.version }} --dir dist
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
-      - name: Verify there is a release asset
-        run: |
-          if [ ! -f dist/taipy-${{ github.event.inputs.version }}.tar.gz ]; then
-            echo "No release asset found"
-            exit 1
-          fi
-
-  publish-pre-release-to-pypi:
-    needs: [verify-dev-package]
-    timeout-minutes: 20
-    environment: publish
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v3
-
-      - name: Download assets from tag
-        run: |
-          gh release download ${{ github.event.inputs.version }} --dir dist
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
-      - name: Publish to PyPI
-        uses: pypa/gh-action-pypi-publish@release/v1
-        with:
-          user: __token__
-          password: ${{ secrets.PYPI_API_TOKEN }}
-
-  test-published-dev-package:
-    needs: [publish-pre-release-to-pypi]
-    timeout-minutes: 30
-    strategy:
-      matrix:
-        python-versions: ['3.8','3.9','3.10', '3.11']
-        os: [ubuntu-latest,windows-latest,macos-latest]
-    runs-on: ${{ matrix.os }}
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/setup-python@v2
-        with:
-          python-version: ${{ matrix.python-versions }}
-
-      - name: Prepare tests on unix
-        if: matrix.os != 'windows-latest'
-        run: |
-          rm -rf src
-
-      - name: Prepare tests on windows
-        if: matrix.os == 'windows-latest'
-        run: |
-          rmdir -Recurse -Force src
-
-      - name: Install and test package
-        run: |
-          pip install --upgrade pip
-          pip install --no-cache-dir ${{ github.event.repository.name }}==${{ github.event.inputs.version }}
-          python -c "import taipy as tp; tp.Scenario"
-          python -c "import taipy as tp; tp.gui"
-          python -c "import taipy as tp; tp.rest"

+ 23 - 45
.github/workflows/publish.yml

@@ -4,7 +4,7 @@ on:
   workflow_dispatch:
     inputs:
       version:
-        description: "The Pypi package version to create (ex: 1.0.0)"
+        description: "The tag of the package to publish on Pypi (ex: 1.0.0, 1.0.0.dev0)"
         required: true
 
 jobs:
@@ -16,55 +16,39 @@ jobs:
       - uses: actions/setup-python@v4
         with:
           python-version: 3.8
-      - uses: actions/setup-node@v3
-        with:
-          node-version: '18'
 
-      - name: Extract branch name
-        shell: bash
-        run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
-        id: extract_branch
+      - name: Extract Github Tag Version
+        id: vars
+        run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
 
       - name: Ensure package version is properly set
         run: |
           echo """
           import json, sys, os
           with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
-              version_o = json.load(version_file)
+            version_o = json.load(version_file)
           version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
           if vext := version_o.get(\"ext\"):
-              version = f'{version}.{vext}'
+            version = f'{version}.{vext}'
           if version != sys.argv[1]:
-              raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
-          """ > /tmp/check1.py
-          python /tmp/check1.py "${{ github.event.inputs.version }}"
-
-      - name: Validate branch name
-        run: |
-          echo """
-          import json, sys, os
-          with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
-              version = json.load(version_file)
-          if f'release/{version.get(\"major\")}.{version.get(\"minor\")}' != sys.argv[1]:
-              raise ValueError(f'Branch name mismatch: release/{version.get(\"major\")}.{version.get(\"minor\")} != {sys.argv[1]}')
+            raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
+          if sys.argv[1] != sys.argv[2]:
+            raise ValueError(f\"Invalid tag version {sys.argv[2]} with package version {sys.argv[1]}\")
           """ > /tmp/check.py
-          python /tmp/check.py "${{ steps.extract_branch.outputs.branch }}"
+          python /tmp/check.py "${{ github.event.inputs.version }}" "${{ steps.vars.outputs.tag }}"
 
-      - name: Install dependencies
+      - name: Download assets from github release tag
         run: |
-          python -m pip install --upgrade pip
-          pip install build
-          pip install "taipy-gui>=<set taipy-gui version here>"
+          gh release download ${{ github.event.inputs.version }} --dir dist
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
-      - name: Build and test the package
+      - name: Verify there is a release asset
         run: |
-          python setup.py build_py && python -m build
-          rm -rf src taipy
-          pip install dist/*.tar.gz
-
-          python -c "import taipy as tp; tp.Scenario"
-          python -c "import taipy as tp; tp.gui"
-          python -c "import taipy as tp; tp.rest"
+          if [ ! -f dist/${{ github.event.repository.name }}-${{ github.event.inputs.version }}.tar.gz ]; then
+            echo "No release asset found"
+            exit 1
+          fi
 
   publish-to-pypi:
     needs: [test-package]
@@ -73,18 +57,12 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
-      - uses: actions/setup-python@v4
-        with:
-          python-version: 3.8
 
-      - name: Install dependencies
+      - name: Download assets from tag
         run: |
-          python -m pip install --upgrade pip
-          pip install build
-          pip install "taipy-gui>=<set taipy-gui version here>"
-
-      - name: Build package
-        run: python setup.py build_py && python -m build
+          gh release download ${{ github.event.inputs.version }} --dir dist
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Publish to PyPI
         uses: pypa/gh-action-pypi-publish@release/v1

+ 79 - 91
.github/workflows/release-dev.yml

@@ -1,4 +1,4 @@
-name: Create Github pre-release
+name: Create Github Dev Release
 
 on:
   workflow_dispatch:
@@ -8,13 +8,11 @@ on:
         required: true
       taipy-rest-version:
         description: "The taipy-rest version to use (ex: 2.3.0.dev0)"
-        required: true
       taipy-templates-version:
         description: "The taipy-templates version to use (ex: 2.3.0.dev0)"
-        required: true
 
 jobs:
-  publish:
+  release-dev-package:
     timeout-minutes: 20
     runs-on: ubuntu-latest
     steps:
@@ -28,21 +26,6 @@ jobs:
         with:
           node-version: '18'
 
-      - name: Extract branch name
-        shell: bash
-        run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
-        id: extract_branch
-
-      - name: Validate branch name (has 'dev' prefix)
-        run: |
-          echo """
-          import sys
-          PREFIX = 'dev'
-          if not sys.argv[1].startswith(PREFIX):
-              raise ValueError(f'Branch name must start with \"{PREFIX}\"')
-          """ > /tmp/check.py
-          python /tmp/check.py "${{ steps.extract_branch.outputs.BRANCH }}"
-
       - name: Ensure package version has 'dev' suffix
         run: |
           echo """
@@ -58,63 +41,68 @@ jobs:
           """ > /tmp/check1.py
           python /tmp/check1.py
 
-      - name: Check dependencies are available
+      - name: Extract package version
+        id: current-version
         run: |
-          curl https://pypi.org/simple/taipy-gui/ | grep -o ">taipy-gui-${{ github.event.inputs.taipy-gui-version }}\.tar\.gz<"
-          curl https://pypi.org/simple/taipy-rest/ | grep -o ">taipy-rest-${{ github.event.inputs.taipy-rest-version }}\.tar\.gz<"
-          curl https://pypi.org/simple/taipy-templates/ | grep -o ">taipy-templates-${{ github.event.inputs.taipy-templates-version }}\.tar\.gz<"
+          echo """
+          import json, os
+          with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
+              version_o = json.load(version_file)
+          version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
+          if vext := version_o.get(\"ext\"):
+              version = f'{version}.{vext}'
+          print(f'VERSION={version}')
+          """ > /tmp/check2.py
+          python /tmp/check2.py >> $GITHUB_OUTPUT
 
-      - name: Grab the version of the package
-        id: current-version
+      - name: Check taipy-gui dependencies
         run: |
-              echo """
-              import json, os
-              with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
-                  version_o = json.load(version_file)
-              version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
-              if vext := version_o.get(\"ext\"):
-                  version = f'{version}.{vext}'
-              print(f'VERSION={version}')
-              """ > /tmp/check2.py
-              python /tmp/check2.py >> $GITHUB_OUTPUT
+          curl https://pypi.org/simple/taipy-gui/ | grep -o ">taipy-gui-${{ github.event.inputs.taipy-gui-version }}\.tar\.gz<"
 
       - name: Install dependencies
         run: |
-            python -m pip install --upgrade pip
-            pip install build
-            pip install "taipy-gui==${{ github.event.inputs.taipy-gui-version }}"
+          python -m pip install --upgrade pip
+          pip install build
+          pip install "taipy-gui==${{ github.event.inputs.taipy-gui-version }}"
 
+      - name: Check dependencies are available
+        if: github.event.inputs.taipy-rest-version != '' && github.event.inputs.taipy-templates-version != ''
+        run: |
+          curl https://pypi.org/simple/taipy-rest/ | grep -o ">taipy-rest-${{ github.event.inputs.taipy-rest-version }}\.tar\.gz<"
+          curl https://pypi.org/simple/taipy-templates/ | grep -o ">taipy-templates-${{ github.event.inputs.taipy-templates-version }}\.tar\.gz<"
+      
       - name: Update setup.py locally
+        if: github.event.inputs.taipy-gui-version != '' && github.event.inputs.taipy-rest-version != '' && github.event.inputs.taipy-templates-version != ''
         run: |
-              mv setup.py setup.taipy.py
-              echo """
-              import sys
-              with open('setup.taipy.py', mode='r') as setup_r, open('setup.py', mode='w') as setup_w:
-                  in_requirements = False
-                  looking = True
-                  for line in setup_r:
-                      if looking:
-                          if line.lstrip().startswith('requirements') and line.rstrip().endswith('['):
-                              in_requirements = True
-                          elif in_requirements:
-                              if line.strip() == ']':
-                                  looking = False
-                              else:
-                                  if line.lstrip().startswith('\"taipy-gui@git+https'):
-                                      start = line.find('\"taipy-gui')
-                                      end = line.rstrip().find(',')
-                                      line = f'{line[:start]}\"taipy-gui=={sys.argv[1]}\"{line[end:]}'
-                                  elif line.lstrip().startswith('\"taipy-rest@git+https'):
-                                      start = line.find('\"taipy-rest')
-                                      end = line.rstrip().find(',')
-                                      line = f'{line[:start]}\"taipy-rest=={sys.argv[2]}\"{line[end:]}'
-                                  elif line.lstrip().startswith('\"taipy-templates@git+https'):
-                                      start = line.find('\"taipy-templates')
-                                      end = line.rstrip().find(',')
-                                      line = f'{line[:start]}\"taipy-templates=={sys.argv[3]}\"{line[end:]}'
-                      setup_w.write(line)
-              """ > /tmp/write_setup_taipy.py
-              python /tmp/write_setup_taipy.py "${{ github.event.inputs.taipy-gui-version }}" "${{ github.event.inputs.taipy-rest-version }}" "${{ github.event.inputs.taipy-templates-version }}"
+          mv setup.py setup.taipy.py
+          echo """
+          import sys
+          with open('setup.taipy.py', mode='r') as setup_r, open('setup.py', mode='w') as setup_w:
+              in_requirements = False
+              looking = True
+              for line in setup_r:
+                  if looking:
+                      if line.lstrip().startswith('requirements') and line.rstrip().endswith('['):
+                          in_requirements = True
+                      elif in_requirements:
+                          if line.strip() == ']':
+                              looking = False
+                          else:
+                              if line.lstrip().startswith('\"taipy-gui@git+https'):
+                                  start = line.find('\"taipy-gui')
+                                  end = line.rstrip().find(',')
+                                  line = f'{line[:start]}\"taipy-gui=={sys.argv[1]}\"{line[end:]}'
+                              elif line.lstrip().startswith('\"taipy-rest@git+https'):
+                                  start = line.find('\"taipy-rest')
+                                  end = line.rstrip().find(',')
+                                  line = f'{line[:start]}\"taipy-rest=={sys.argv[2]}\"{line[end:]}'
+                              elif line.lstrip().startswith('\"taipy-templates@git+https'):
+                                  start = line.find('\"taipy-templates')
+                                  end = line.rstrip().find(',')
+                                  line = f'{line[:start]}\"taipy-templates=={sys.argv[3]}\"{line[end:]}'
+                  setup_w.write(line)
+          """ > /tmp/write_setup_taipy.py
+          python /tmp/write_setup_taipy.py "${{ github.event.inputs.taipy-gui-version }}" "${{ github.event.inputs.taipy-rest-version }}" "${{ github.event.inputs.taipy-templates-version }}"
 
       - name: Build package
         run: python setup.py build_py && python -m build
@@ -123,7 +111,7 @@ jobs:
         run: |
           # Install package
           echo "Installing package..."
-          pip install ./dist/taipy-${{ steps.current-version.outputs.VERSION }}.tar.gz
+          pip install ./dist/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz
 
           # Run tests
           python -c "import taipy as tp; tp.Scenario"
@@ -137,39 +125,39 @@ jobs:
 
       - name: Create/update release and tag
         run: |
-            echo "Creating release ${{ steps.current-version.outputs.VERSION }}"
-            gh release create ${{ steps.current-version.outputs.VERSION }} ./dist/taipy-${{ steps.current-version.outputs.VERSION }}.tar.gz --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title ${{ steps.current-version.outputs.VERSION }} --notes "Release Draft ${{ steps.current-version.outputs.VERSION }}"
+          echo "Creating release ${{ steps.current-version.outputs.VERSION }}"
+          gh release create ${{ steps.current-version.outputs.VERSION }} ./dist/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title ${{ steps.current-version.outputs.VERSION }} --notes "Release Draft ${{ steps.current-version.outputs.VERSION }}"
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Reset changes
         run: |
-              git reset --hard HEAD
-              git clean -fdx
+          git reset --hard HEAD
+          git clean -fdx
 
       - name: Increase dev version
         id: new-version
         run: |
-              echo """
-              import json, os
-              with open(f'src{os.sep}taipy{os.sep}version.json') as version_file:
+          echo """
+          import json, os
+          with open(f'src{os.sep}taipy{os.sep}version.json') as version_file:
+              version_o = json.load(version_file)
+              if version_o is None or 'dev' not in version_o['ext']:
+                  raise ValueError('Invalid version file. Version must contain dev suffix.')
+              prev_version = version_o['ext']
+              new_version = 'dev' + str(int(version_o['ext'].replace('dev', '')) + 1)
+              with open(f'src{os.sep}taipy{os.sep}version.json') as r:
+                  text = r.read().replace(prev_version, new_version)
+              with open(f'src{os.sep}taipy{os.sep}version.json', mode='w') as w:
+                  w.write(text)
+              with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
                   version_o = json.load(version_file)
-                  if version_o is None or 'dev' not in version_o['ext']:
-                      raise ValueError('Invalid version file. Version must contain dev suffix.')
-                  prev_version = version_o['ext']
-                  new_version = 'dev' + str(int(version_o['ext'].replace('dev', '')) + 1)
-                  with open(f'src{os.sep}taipy{os.sep}version.json') as r:
-                      text = r.read().replace(prev_version, new_version)
-                  with open(f'src{os.sep}taipy{os.sep}version.json', mode='w') as w:
-                      w.write(text)
-                  with open(f\"src{os.sep}taipy{os.sep}version.json\") as version_file:
-                      version_o = json.load(version_file)
-                  version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
-                  if vext := version_o.get(\"ext\"):
-                      version = f'{version}.{vext}'
-                  print(f'VERSION={version}')
-              """ > /tmp/increase_dev_version.py
-              python /tmp/increase_dev_version.py >> $GITHUB_OUTPUT
+              version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
+              if vext := version_o.get(\"ext\"):
+                  version = f'{version}.{vext}'
+              print(f'VERSION={version}')
+          """ > /tmp/increase_dev_version.py
+          python /tmp/increase_dev_version.py >> $GITHUB_OUTPUT
 
       - uses: stefanzweifel/git-auto-commit-action@v4
         with:

+ 25 - 13
.github/workflows/release.yml

@@ -8,7 +8,7 @@ on:
         required: true
 
 jobs:
-  test-package:
+  release-package:
     timeout-minutes: 20
     runs-on: ubuntu-latest
     steps:
@@ -44,13 +44,34 @@ jobs:
               version = json.load(version_file)
           if f'release/{version.get(\"major\")}.{version.get(\"minor\")}' != sys.argv[1]:
               raise ValueError(f'Branch name mismatch: release/{version.get(\"major\")}.{version.get(\"minor\")} != {sys.argv[1]}')
-          """ > /tmp/check.py
-          python /tmp/check.py "${{ steps.extract_branch.outputs.branch }}"
+          """ > /tmp/check2.py
+          python /tmp/check2.py "${{ steps.extract_branch.outputs.branch }}"
+      
+      - name: Modify README image file path
+        run: |
+          cp tools/modify_readme.py /tmp
+          python /tmp/modify_readme.py "${{ github.event.repository.name }}" "${{ steps.extract_branch.outputs.branch }}"
+
+      - name: Get taipy-gui version from setup.py
+        id: taipy_gui_version
+        run: |
+          echo """
+          with open('setup.py') as f:
+              for line in f:
+                  if 'taipy-gui' in line:
+                      start = line.find('taipy-gui')
+                      end = line.rstrip().find('\",')
+                      print(f'VERSION={line[start:end]}')
+                      break
+          """ > /tmp/get_gui_version.py
+          python /tmp/get_gui_version.py >> $GITHUB_OUTPUT
 
       - name: Install dependencies
         run: |
           python -m pip install --upgrade pip
           pip install build
+          # install taipy-gui from based on setup.py version
+          pip install "{{ steps.taipy_gui_version.outputs.VERSION }}"
 
       - name: Build and test the package
         run: |
@@ -61,15 +82,6 @@ jobs:
           python -c "import taipy as tp; tp.gui"
           python -c "import taipy as tp; tp.rest"
 
-  release:
-    needs: [test-package]
-    timeout-minutes: 20
-    name: Release Package
-    runs-on: ubuntu-latest
-
-    steps:
-      - uses: actions/checkout@v3
-
       - name: Extract commit hash
         shell: bash
         run: echo "HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
@@ -77,6 +89,6 @@ jobs:
 
       - name: Create/update release and tag
         run: |
-            gh release create ${{ github.event.inputs.version }} --target ${{ steps.extract_hash.outputs.HASH }} --title ${{ github.event.inputs.version }}
+            gh release create ${{ github.event.inputs.version }} ./dist/${{ github.event.repository.name }}-${{ github.event.inputs.version }}.tar.gz --target ${{ steps.extract_hash.outputs.HASH }} --title ${{ github.event.inputs.version }}
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 15 - 0
tools/modify_readme.py

@@ -0,0 +1,15 @@
+import re
+import sys
+
+repo_name = sys.argv[1]
+branch_name = sys.argv[2]
+# Regex pattern <img\s+([^>]*?)(?<!['"])(?<!\/)src\s*=\s*(['"])(?!http|\/)(.*?)\2([^>]*?)>
+pattern = re.compile("<img\\s+([^>]*?)(?<!['\"])(?<!\\/)src\\s*=\\s*(['\"])(?!http|\\/)(.*?)\\2([^>]*?)>")
+replacement = r'<img \1src="https://raw.githubusercontent.com/Avaiga/{repo_name}/{branch_name}/\3"\4>'
+
+with open("README.md") as readme_file:
+    readme_str = readme_file.read()
+    modified_readme = re.sub(pattern, replacement.format(repo_name=repo_name, branch_name=branch_name), readme_str)
+
+with open("README.md", "w") as readme_file:
+    readme_file.write(modified_readme)