Pārlūkot izejas kodu

Add the new release process (#37)

* Add the new release process

* Remove old SSH settings
Vuillemot Florian 3 gadi atpakaļ
vecāks
revīzija
cb808586d4

+ 85 - 12
.github/workflows/publish.yml

@@ -1,19 +1,63 @@
-# This workflow will upload a Python Package using Twine when a release is created
-# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
-
-# This workflow uses actions that are not certified by GitHub.
-# They are provided by a third-party and are governed by
-# separate terms of service, privacy policy, and support
-# documentation.
-
-name: Publish package
+name: Publish on Pypi
 
 
 on:
 on:
   workflow_dispatch:
   workflow_dispatch:
+    inputs:
+      version:
+        description: "The Pypi package version to create (ex: 1.0.0)"
+        required: true
 
 
 jobs:
 jobs:
+  test-package:
+    timeout-minutes: 20
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-python@v2
+        with:
+          python-version: 3.8
+
+      - name: Extract branch name
+        shell: bash
+        run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
+        id: extract_branch
+
+      - name: Ensure package version is properly set
+        run: |
+          echo 'version="${{ github.event.inputs.version }}"' | grep -f - setup.py
+
+      - name: Validate branch name
+        run: |
+          echo """
+          import re, sys
+          setup = open('setup.py').read()
+          x = re.search(r'version=\"(\d+)\.(\d+)\.(\d+)(?:\.([a-zA-Z0-9_]+))?\"', setup)
+          if not x:
+              raise ValueError('Invalid version expression')
+          if f'release/{x.group(1)}.{x.group(2)}' != sys.argv[1]:
+              raise ValueError('Branch name mismatch')
+          """ > /tmp/check.py
+          python /tmp/check.py "${{ steps.extract_branch.outputs.branch }}"
+
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install build
+
+      - name: Build and test the package
+        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"
+
   publish-to-pypi:
   publish-to-pypi:
-    environment: production
+    needs: [test-package]
+    timeout-minutes: 20
+    environment: publish
     runs-on: ubuntu-18.04
     runs-on: ubuntu-18.04
     steps:
     steps:
       - uses: actions/checkout@v2
       - uses: actions/checkout@v2
@@ -35,5 +79,34 @@ jobs:
           user: __token__
           user: __token__
           password: ${{ secrets.PYPI_API_TOKEN }}
           password: ${{ secrets.PYPI_API_TOKEN }}
 
 
-      - name: Install package from PyPI
-        run: pip install ${{ github.event.repository.name }}
+  test-published-package:
+    needs: [publish-to-pypi]
+    timeout-minutes: 30
+    strategy:
+      matrix:
+        python-versions: ['3.8','3.9','3.10']
+        os: [ubuntu-18.04,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 taipy
+
+      - name: Prepare tests on windows
+        if: matrix.os == 'windows-latest'
+        run: |
+          rmdir -Recurse -Force taipy
+
+      - 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"

+ 74 - 0
.github/workflows/release.yml

@@ -0,0 +1,74 @@
+name: Create Github Release
+
+on:
+  workflow_dispatch:
+    inputs:
+      version:
+        description: "The release/package version to create (ex: 1.0.0)"
+        required: true
+
+jobs:
+  test-package:
+    timeout-minutes: 20
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-python@v2
+        with:
+          python-version: 3.8
+
+      - name: Extract branch name
+        shell: bash
+        run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
+        id: extract_branch
+
+      - name: Ensure package version is properly set
+        run: |
+          echo 'version="${{ github.event.inputs.version }}"' | grep -f - setup.py
+
+      - name: Validate branch name
+        run: |
+          echo """
+          import re, sys
+          setup = open('setup.py').read()
+          x = re.search(r'version=\"(\d+)\.(\d+)\.(\d+)(?:\.([a-zA-Z0-9_]+))?\"', setup)
+          if not x:
+              raise ValueError('Invalid version expression')
+          if f'release/{x.group(1)}.{x.group(2)}' != sys.argv[1]:
+              raise ValueError('Branch name mismatch')
+          """ > /tmp/check.py
+          python /tmp/check.py "${{ steps.extract_branch.outputs.branch }}"
+
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install build
+
+      - name: Build and test the package
+        run: |
+          python setup.py build_py && python -m build
+          rm -rf 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"
+
+  release:
+    needs: [test-package]
+    timeout-minutes: 20
+    name: Release Package
+    runs-on: ubuntu-18.04
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Extract commit hash
+        shell: bash
+        run: echo "##[set-output name=hash;]$(echo $(git rev-parse HEAD))"
+        id: extract_hash
+
+      - name: Create/update release and tag
+        run: |
+            gh release create ${{ github.event.inputs.version }} --target ${{ steps.extract_hash.outputs.hash }} --notes "Release created using Github Workflows"
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 0 - 5
.github/workflows/setuptools.yml

@@ -30,11 +30,6 @@ jobs:
 
 
       - name: Install Taipy without dependencies
       - name: Install Taipy without dependencies
         run: |
         run: |
-          mkdir -p ~/.ssh
-          echo "${{ secrets.SSH_KEY_TAIPY_CORE }}" > ~/.ssh/id_ed25519
-          ssh-keyscan github.com >> ~/.ssh/known_hosts
-          chmod 600 ~/.ssh/id_ed25519
-
           pip install .
           pip install .
           rm -r taipy
           rm -r taipy