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 #20

Workflow file for this run

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@v3
- uses: actions/setup-python@v2
with:
python-version: 3.8
- 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}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]}\")
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 "${{ 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/${{ 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]
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-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@v3
- 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 }}