This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
162 lines (144 loc) · 6.64 KB
/
release-dev.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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 }}