This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
141 lines (125 loc) · 5.87 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
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 }}