Publish on Pypi #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish on Pypi | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The tag of the package to publish on Pypi (ex: 1.0.0, 1.0.0.dev0)" | |
required: true | |
jobs: | |
test-package: | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Extract Github Tag Version | |
id: vars | |
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- 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 if all releases exist | |
run: | | |
python tools/release/check_releases.py dist ${{ github.event.inputs.version }} | |
publish-subpackages-to-pypi: | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
needs: [test-package] | |
timeout-minutes: 20 | |
strategy: | |
matrix: | |
package: [ config, core, gui, rest, templates ] | |
max-parallel: 1 | |
environment: publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: taipy/${{ matrix.package }} | |
sparse-checkout-cone-mode: false | |
- name: Checks if package is already on Pypi | |
id: check-version | |
run: | | |
if curl https://pypi.org/simple/taipy-${{ matrix.package }} | grep -o ">taipy-${{ matrix.package }}-${{ github.event.inputs.version }}\.tar\.gz<"; then | |
echo "exists=true" >> $GITHUB_OUTPUT | |
else | |
echo "exists=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Download assets from tag | |
if: steps.check-version.outputs.exists == 'false' | |
run: | | |
gh release download ${{ github.event.inputs.version }}-${{ matrix.package }} --dir dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to PyPI | |
if: steps.check-version.outputs.exists == 'false' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-main-package-to-pypi: | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
needs: [publish-subpackages-to-pypi, test-package ] | |
timeout-minutes: 20 | |
environment: publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checks if package is already on on Pypi | |
id: check-version | |
run: | | |
if curl https://pypi.org/simple/taipy | grep -o ">taipy-${{ github.event.inputs.version }}\.tar\.gz<"; then | |
echo "exists=true" >> $GITHUB_OUTPUT | |
else | |
echo "exists=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Download assets from tag | |
if: steps.check-version.outputs.exists == 'false' | |
run: | | |
gh release download ${{ github.event.inputs.version }} --dir dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to PyPI | |
if: steps.check-version.outputs.exists == 'false' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
test-published-package: | |
needs: [publish-main-package-to-pypi] | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
python-versions: ['3.8','3.9','3.10', '3.11', '3.12'] | |
os: [ubuntu-latest,windows-latest,macos-13] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
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 tools/validate_taipy_install.py |