This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
Create Github Dev Release #20
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: Create Github Dev Release | |
on: | |
workflow_dispatch: | |
inputs: | |
taipy-config-version: | |
description: "The taipy-config version to use (ex: 1.0.0.dev0)" | |
jobs: | |
release-dev-package: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{secrets.DEPLOY_KEY}} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Ensure package version has 'dev' suffix | |
run: | | |
echo """ | |
import json, sys, os | |
SUFFIX = 'dev' | |
with open(f\"src{os.sep}taipy{os.sep}gui{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}\") | |
""" > ${{ runner.temp }}/check1.py | |
python ${{ runner.temp }}/check1.py | |
- name: Extract package version | |
id: current-version | |
run: | | |
echo """ | |
import json, os | |
with open(f\"src{os.sep}taipy{os.sep}gui{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}') | |
""" > ${{ runner.temp }}/check2.py | |
python ${{ runner.temp }}/check2.py >> $GITHUB_OUTPUT | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Check dependencies are available | |
if: github.event.inputs.taipy-config-version != '' | |
run: | | |
curl https://pypi.org/simple/taipy-config/ | grep -o ">taipy-config-${{ github.event.inputs.taipy-config-version }}\.tar\.gz<" | |
- name: Update setup.py locally | |
if: github.event.inputs.taipy-config-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-config@git+https'): | |
start = line.find('\"taipy-config') | |
end = line.rstrip().find(',') | |
line = f'{line[:start]}\"taipy-config=={sys.argv[1]}\"{line[end:]}' | |
setup_w.write(line) | |
""" > ${{ runner.temp }}/write_setup_taipy.py | |
python ${{ runner.temp }}/write_setup_taipy.py "${{ github.event.inputs.taipy-config-version }}" | |
- name: Generate pyi files | |
run: | | |
pip install pipenv==2023.7.23 | |
pipenv install --dev | |
cp tools/generate_pyi.py temp.py && pipenv run python temp.py && rm temp.py | |
pipenv --rm | |
- name: Build package | |
run: python setup.py build_py && python -m build | |
- name: Install the package and test it | |
run: | | |
# Install package | |
echo "Installing package..." | |
pip install ./dist/taipy-gui-${{ steps.current-version.outputs.VERSION }}.tar.gz | |
rm -r src | |
# Install test packages | |
echo "Installing test packages..." | |
pip install pytest pytest-mock playwright pytest-playwright pytest-timeout testbook | |
pip install ipython ipykernel | |
ipython kernel install --name "python3" --user | |
playwright install chromium --with-deps | |
# Run tests | |
echo "running pytest" | |
pytest -s | |
echo "running test import tp" | |
python -c "import taipy as tp; tp.Gui" | |
- name: Extract commit hash | |
shell: bash | |
run: echo "HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
id: extract_hash | |
- name: Create/update release and tag | |
run: | | |
echo "Creating release dev-${{ steps.current-version.outputs.VERSION }}" | |
gh release create ${{ steps.current-version.outputs.VERSION }} ./dist/taipy-gui-${{ 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 | |
- name: Increase dev version | |
id: new-version | |
run: | | |
echo """ | |
import json, os | |
with open(f'src{os.sep}taipy{os.sep}gui{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}gui{os.sep}version.json') as r: | |
text = r.read().replace(prev_version, new_version) | |
with open(f'src{os.sep}taipy{os.sep}gui{os.sep}version.json', mode='w') as w: | |
w.write(text) | |
with open(f\"src{os.sep}taipy{os.sep}gui{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}') | |
""" > ${{ runner.temp }}/increase_dev_version.py | |
python ${{ runner.temp }}/increase_dev_version.py >> $GITHUB_OUTPUT | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Update version to ${{ steps.new-version.outputs.VERSION }} |