Skip to content

Commit f5ae84b

Browse files
authored
initial release (#1)
1 parent 1b704d8 commit f5ae84b

File tree

8 files changed

+271
-53
lines changed

8 files changed

+271
-53
lines changed

.github/workflows/pytest.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: pytest
2+
3+
on:
4+
push:
5+
branches: [ master, dev ]
6+
pull_request:
7+
branches: [ master, dev ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out repository code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt
26+
# Устанавливаем пакет в режиме редактирования для корректных импортов в тестах
27+
pip install -e .
28+
29+
- name: Run tests with pytest
30+
run: |
31+
pytest

.github/workflows/python-pytest.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
check-branch:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
on_master: ${{ steps.check.outputs.on_master }}
16+
steps:
17+
- name: Check out repository code on master
18+
uses: actions/checkout@v4
19+
with:
20+
ref: 'master'
21+
fetch-depth: 0
22+
23+
- name: Check if tag commit is on master branch
24+
id: check
25+
run: |
26+
# Get the commit SHA of the pushed tag
27+
TAG_COMMIT_SHA=$(git rev-parse ${{ github.ref }})
28+
echo "Tag commit SHA: $TAG_COMMIT_SHA"
29+
30+
# Check if this commit is an ancestor of the master branch HEAD (current checkout)
31+
# Use 'git branch --contains <commit>' is another way, but requires fetching all branches potentially
32+
if git merge-base --is-ancestor $TAG_COMMIT_SHA HEAD; then
33+
echo "Tag commit is on master branch."
34+
echo "on_master=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "Tag commit is NOT on master branch."
37+
echo "on_master=false" >> $GITHUB_OUTPUT
38+
fi
39+
40+
test:
41+
needs: check-branch
42+
if: needs.check-branch.outputs.on_master == 'true'
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Check out repository code for the tag
46+
uses: actions/checkout@v4
47+
with:
48+
ref: ${{ github.ref }}
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v4
52+
with:
53+
python-version: '3.12'
54+
55+
- name: Install dependencies
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install -r requirements.txt
59+
pip install -e .
60+
61+
- name: Run tests with pytest
62+
run: |
63+
pytest
64+
65+
build-package:
66+
needs:
67+
- check-branch
68+
- test
69+
if: needs.check-branch.outputs.on_master == 'true'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Check out repository code for the tag
73+
uses: actions/checkout@v4
74+
with:
75+
ref: ${{ github.ref }}
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v4
79+
with:
80+
python-version: '3.12'
81+
82+
- name: Install dependencies
83+
run: |
84+
python -m pip install --upgrade pip
85+
pip install -r requirements.txt
86+
pip install build
87+
88+
- name: Build package
89+
run: |
90+
python setup.py sdist bdist_wheel
91+
92+
- name: Upload package artifacts
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: python-packages
96+
path: dist/
97+
98+
build-native:
99+
needs:
100+
- check-branch
101+
- test
102+
if: needs.check-branch.outputs.on_master == 'true'
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Check out repository code for the tag
106+
uses: actions/checkout@v4
107+
with:
108+
ref: ${{ github.ref }}
109+
110+
- name: Set up Python
111+
uses: actions/setup-python@v4
112+
with:
113+
python-version: '3.12'
114+
115+
- name: Install dependencies
116+
run: |
117+
python -m pip install --upgrade pip
118+
pip install -r requirements.txt
119+
pip install build
120+
121+
- name: Build native
122+
run: |
123+
python build_native.py
124+
mv dist_native/xmlgenerator dist_native/xmlgenerator-linux-amd64
125+
126+
- name: Upload native artifact
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: native-binary
130+
path: dist_native/xmlgenerator-linux-amd64
131+
132+
create-release:
133+
needs:
134+
- check-branch
135+
- build-package
136+
- build-native
137+
if: needs.check-branch.outputs.on_master == 'true'
138+
runs-on: ubuntu-latest
139+
steps:
140+
- name: Download Python packages
141+
uses: actions/download-artifact@v4
142+
with:
143+
name: python-packages
144+
path: dist
145+
146+
- name: Download native binary
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: native-binary
150+
path: dist_native
151+
152+
- name: Create Release
153+
uses: softprops/action-gh-release@v2
154+
id: create_release
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
with:
158+
name: ${{ github.ref_name }}
159+
files: |
160+
dist/*.whl
161+
dist/*.tar.gz
162+
dist_native/xmlgenerator-linux-amd64
163+
164+
publish-package:
165+
needs:
166+
- check-branch
167+
- build-package
168+
if: needs.check-branch.outputs.on_master == 'true'
169+
runs-on: ubuntu-latest
170+
steps:
171+
- name: Download Python packages
172+
uses: actions/download-artifact@v4
173+
with:
174+
name: python-packages
175+
path: dist
176+
177+
- name: Publish package to PyPI
178+
env:
179+
TWINE_USERNAME: __token__
180+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
181+
run: |
182+
twine upload dist/*

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Simplifies the creation of test or demonstration XML data for complex schemas.
1515

1616
## Installation
1717

18-
[//]: # (### Installation via pip &#40;once published on PyPI&#41;)
19-
[//]: # ()
20-
[//]: # (```bash)
21-
[//]: # (pip install xmlgenerator)
22-
[//]: # (```)
18+
### Installation via pip
19+
20+
```bash
21+
pip install xmlgenerator
22+
```
2323

2424
### Build from source
2525

@@ -47,13 +47,18 @@ Simplifies the creation of test or demonstration XML data for complex schemas.
4747
pip install -r requirements.txt
4848
```
4949

50-
4. **Install the package:**
50+
4.1. **Install the package:**
5151
```bash
5252
pip install .
5353
# or for development mode (code changes will be immediately reflected)
5454
# pip install -e .
5555
```
5656

57+
4.2. **Otherwise, build single executable:**
58+
```bash
59+
python build_native.py
60+
```
61+
5762
## CLI Usage
5863

5964
The main command to run the generator is `xmlgenerator`.
@@ -80,6 +85,13 @@ The main command to run the generator is `xmlgenerator`.
8085
xmlgenerator -v none path/to/your/schema.xsd
8186
```
8287

88+
**Install shell completions:**
89+
90+
```shell
91+
# also available: zsh, tcsh
92+
xmlgenerator -C bash | sudo tee /etc/bash_completion.d/xmlgenerator
93+
```
94+
8395
**Detailed CLI Usage:**
8496

8597
```
@@ -103,6 +115,7 @@ options:
103115
--seed <seed> set randomization seed
104116
-d, --debug enable debug mode
105117
-V, --version shows current version
118+
-C, --completion <shell> print shell completion script (bash, zsh, tcsh)
106119
```
107120
108121
## Configuration
@@ -258,8 +271,6 @@ Contributions are welcome! Please open an issue or submit a pull request on GitH
258271
pytest
259272
```
260273

261-
(Ensure `pytest` is installed, e.g., via `pip install pytest` or included in `requirements-dev.txt`)
262-
263274
---
264275

265276
## License

README_RU.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515

1616
## Установка
1717

18-
[//]: # (### Установка через pip &#40;когда будет опубликован на PyPI&#41;)
18+
### Установка через pip
1919

20-
[//]: # ()
21-
22-
[//]: # (```bash)
23-
24-
[//]: # (pip install xmlgenerator)
25-
26-
[//]: # (```)
20+
```bash
21+
pip install xmlgenerator
22+
```
2723

2824
### Сборка из исходников
2925

@@ -51,13 +47,18 @@
5147
pip install -r requirements.txt
5248
```
5349

54-
4. **Установите пакет:**
50+
4.1. **Установите пакет:**
5551
```bash
5652
pip install .
5753
# или для режима разработки (изменения в коде будут сразу видны)
5854
# pip install -e .
5955
```
6056

57+
4.2. **Или соберите единый исполняемый файл:**
58+
```bash
59+
python build_native.py
60+
```
61+
6162
## Использование CLI
6263

6364
Основная команда для запуска генератора - `xmlgenerator`.
@@ -84,6 +85,13 @@
8485
xmlgenerator -v none path/to/your/schema.xsd
8586
```
8687

88+
**Установить автодополнения:**
89+
90+
```shell
91+
# также доступны: zsh, tcsh
92+
xmlgenerator -C bash | sudo tee /etc/bash_completion.d/xmlgenerator
93+
```
94+
8795
**Детальное описание использования CLI:**
8896

8997
```
@@ -107,6 +115,7 @@ options:
107115
--seed <seed> set randomization seed
108116
-d, --debug enable debug mode
109117
-V, --version shows current version
118+
-C, --completion <shell> print shell completion script (bash, zsh, tcsh)
110119
```
111120
112121
## Конфигурация
@@ -262,8 +271,6 @@ specific:
262271
pytest
263272
```
264273

265-
(Ensure `pytest` is installed, e.g., via `pip install pytest` or included in `requirements-dev.txt`)
266-
267274
---
268275

269276
## Лицензия

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ xmlschema==3.4.3
33
Faker==37.0.0
44
rstr==3.2.2
55
PyYAML==6.0.2
6+
shtab
67

78
# dev
89
pytest==8.3.5
910
setuptools==77.0.3
1011
nuitka
12+
twine

0 commit comments

Comments
 (0)