Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Publish on Pypi

Publish on Pypi #22

Workflow file for this run

name: Publish on Pypi
on:
workflow_dispatch:
inputs:
version:
description: "The Pypi package version to create (ex: 1.0.0)"
required: true
jobs:
test-package:
timeout-minutes: 20
runs-on: ubuntu-latest
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 """
import json, sys, os
with open(f\"src{os.sep}taipy{os.sep}config{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]}\")
""" > /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}config{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]}')
""" > /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
pip install dist/*.tar.gz
publish-to-pypi:
needs: [test-package]
timeout-minutes: 20
environment: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py build_py && python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
test-published-package:
needs: [publish-to-pypi]
timeout-minutes: 30
strategy:
matrix:
python-versions: ['3.8','3.9','3.10']
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: Install and test package
run: |
pip install --upgrade pip
pip install --no-cache-dir ${{ github.event.repository.name }}==${{ github.event.inputs.version }}