-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (135 loc) · 4.58 KB
/
stable.yml
File metadata and controls
151 lines (135 loc) · 4.58 KB
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
name: JE_Editor Stable
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
inputs:
bump:
description: "Version bump level"
required: true
default: "patch"
type: choice
options: [patch, minor, major]
permissions:
contents: read
concurrency:
group: stable-publish-${{ github.ref }}
cancel-in-progress: false
jobs:
build_stable_version:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r dev_requirements.txt
pip install -e .
- name: Run unit tests
run: python -m pytest test/ -v --tb=short --ignore=test/qt_ui
- name: Test Start Editor
timeout-minutes: 2
env:
QT_QPA_PLATFORM: offscreen
run: python ./test/qt_ui/unit_test/start_qt_ui.py
shell: cmd
- name: Test Extend Editor
timeout-minutes: 2
env:
QT_QPA_PLATFORM: offscreen
run: python ./test/qt_ui/unit_test/extend_test.py
shell: cmd
publish_to_pypi:
needs: build_stable_version
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tooling
run: |
python -m pip install --upgrade pip
pip install build tomli tomli-w
- name: Bump version in pyproject.toml
id: bump
env:
BUMP_LEVEL: ${{ github.event.inputs.bump || 'patch' }}
run: |
python - <<'PY'
import os, re, tomli, tomli_w, pathlib
level = os.environ["BUMP_LEVEL"]
path = pathlib.Path("pyproject.toml")
data = tomli.loads(path.read_text(encoding="utf-8"))
current = data["project"]["version"]
parts = [int(x) for x in current.split(".")]
while len(parts) < 3:
parts.append(0)
major, minor, patch = parts[:3]
if level == "major":
major, minor, patch = major + 1, 0, 0
elif level == "minor":
minor, patch = minor + 1, 0
else:
patch += 1
new_version = f"{major}.{minor}.{patch}"
text = path.read_text(encoding="utf-8")
new_text = re.sub(
r'(^version\s*=\s*")[^"]+(")',
rf'\g<1>{new_version}\g<2>',
text,
count=1,
flags=re.MULTILINE,
)
path.write_text(new_text, encoding="utf-8")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
fh.write(f"old_version={current}\n")
fh.write(f"new_version={new_version}\n")
print(f"Bumped {current} -> {new_version} ({level})")
PY
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
git tag "v${{ steps.bump.outputs.new_version }}"
git push origin main
git push origin "v${{ steps.bump.outputs.new_version }}"
- name: Build distribution
run: python -m build
- name: Publish to PyPI
# Pinned to full SHA of pypa/gh-action-pypi-publish release/v1
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
OLD_VERSION: ${{ steps.bump.outputs.old_version }}
run: |
gh release create "v${NEW_VERSION}" \
--title "v${NEW_VERSION}" \
--notes "Release v${NEW_VERSION} (bumped from v${OLD_VERSION}). Published to PyPI." \
dist/*