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

Create Github Dev Release #17

Create Github Dev Release

Create Github Dev Release #17

Workflow file for this run

name: Create Github Dev Release
on:
workflow_dispatch:
inputs:
taipy-config-version:
description: "The taipy-config version to use (ex: 2.3.0.dev0)"
jobs:
release-dev-package:
timeout-minutes: 20
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
- name: Ensure package version has 'dev' suffix
run: |
echo """
import json, sys, os
SUFFIX = 'dev'
with open(f\"src{os.sep}taipy{os.sep}core{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}\")
""" > /tmp/check1.py
python /tmp/check1.py
- name: Extract package version
id: current-version
run: |
echo """
import json, os
with open(f\"src{os.sep}taipy{os.sep}core{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}')
""" > /tmp/check2.py
python /tmp/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)
""" > /tmp/write_setup_taipy.py
python /tmp/write_setup_taipy.py "${{ github.event.inputs.taipy-config-version }}"
- 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/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz
# Run tests
python -c "import taipy as tp; tp.Scenario"
- 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: |
echo "Creating release ${{ steps.current-version.outputs.VERSION }}"
gh release create ${{ steps.current-version.outputs.VERSION }} ./dist/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz --target ${{ steps.extract_hash.outputs.hash }} --prerelease --title ${{ steps.current-version.outputs.VERSION }} --notes "Dev Release ${{ 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}core{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}core{os.sep}version.json') as r:
text = r.read().replace(prev_version, new_version)
with open(f'src{os.sep}taipy{os.sep}core{os.sep}version.json', mode='w') as w:
w.write(text)
with open(f\"src{os.sep}taipy{os.sep}core{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}')
""" > /tmp/increase_dev_version.py
python /tmp/increase_dev_version.py >> $GITHUB_OUTPUT
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update version to ${{ steps.new-version.outputs.VERSION }}