Skip to content

Commit d92e867

Browse files
committed
Add CI
1 parent 362b831 commit d92e867

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

.ci/patch_pubspec_version.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
import pathlib
3+
import sys
4+
5+
import yaml
6+
7+
if len(sys.argv) < 3:
8+
print("Specify pubspec.yaml file and version to patch")
9+
sys.exit(1)
10+
11+
current_dir = pathlib.Path(os.getcwd())
12+
pubspec_path = current_dir.joinpath(current_dir, sys.argv[1])
13+
ver = sys.argv[2]
14+
print(f"Patching pubspec.yaml file {pubspec_path} with {ver}")
15+
16+
dependencies = [
17+
"flet",
18+
]
19+
20+
with open(pubspec_path, "r") as f:
21+
data = yaml.safe_load(f)
22+
23+
# patch version
24+
data["version"] = ver
25+
26+
with open(pubspec_path, "w") as file:
27+
yaml.dump(data, file, sort_keys=False)

.ci/patch_toml_version.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
import pathlib
3+
import sys
4+
5+
import tomlkit
6+
7+
if len(sys.argv) < 3:
8+
print("Specify toml file and version to patch")
9+
sys.exit(1)
10+
11+
current_dir = pathlib.Path(os.getcwd())
12+
toml_path = current_dir.joinpath(current_dir, sys.argv[1])
13+
ver = sys.argv[2]
14+
print(f"Patching TOML file {toml_path} to {ver}")
15+
16+
# read
17+
with open(toml_path, "r") as f:
18+
t = tomlkit.parse(f.read())
19+
20+
# patch version
21+
t["project"]["version"] = ver
22+
23+
# save
24+
with open(toml_path, "w") as f:
25+
f.write(tomlkit.dumps(t))

.ci/update_build_version.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if [ -n "$APPVEYOR_REPO_TAG_NAME" ]; then
2+
export PKG_VER="${APPVEYOR_REPO_TAG_NAME#v}" # Remove the 'v' prefix
3+
export BUILD_VER="$PKG_VER"
4+
else
5+
# Get the latest Git tag and handle missing tags gracefully
6+
cv=$(git describe --abbrev=0 2>/dev/null || echo "v0.0.0") # Default to v1.0.0 if no tag
7+
cv=${cv#v} # Remove the 'v' prefix if present
8+
major=$(echo "$cv" | cut -d. -f1)
9+
minor=$(echo "$cv" | cut -d. -f2)
10+
minor=$((minor + 1))
11+
export PKG_VER="${major}.${minor}.0"
12+
export BUILD_VER="${PKG_VER}+${APPVEYOR_BUILD_NUMBER}"
13+
fi
14+
export PYPI_VER="${BUILD_VER/+/.dev}"
15+
appveyor UpdateBuild -Version $BUILD_VER

appveyor.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
image: ubuntu
2+
3+
version: '0.1.{build}'
4+
5+
environment:
6+
UV_PUBLISH_TOKEN:
7+
secure: 174ncAbF5IjSIkmioPt62jeSnzmTlRNchUkE4QdjDWH8xK1olYtySXLJpo2q95HcP7lWJky1hv4APESiRRHnBWoY0XRFafzM/mbCDMzG1tZXiXZmpP1qzHAtRP2QSCIg18xh1TMktraUdTi7sbJnjjRhqzgbW1k0kLBxKw79MPFBhYQ/TiGcmaYWZbWVZNY3HCUCb6Dt7bG1OE2Ul9rD1gvs55xwO9Oq9FOVA1VnMYw=
8+
9+
stack:
10+
- python 3.12
11+
12+
install:
13+
- source .ci/update_build_version.sh
14+
- python --version
15+
- python -m ensurepip --upgrade
16+
- pip3 install --upgrade tomlkit pyyaml
17+
- curl -LsSf https://astral.sh/uv/install.sh | sh
18+
- export PATH=$HOME/.local/bin:$PATH
19+
20+
build_script:
21+
- python .ci/patch_toml_version.py pyproject.toml $PYPI_VER
22+
- python .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER
23+
- (cd src/flutter/* && dart pub get && dart analyze && cd -)
24+
- uv build
25+
26+
deploy_script:
27+
- sh: |
28+
if [[ ("$APPVEYOR_REPO_BRANCH" == "main" || "$APPVEYOR_REPO_TAG_NAME" != "") && "$APPVEYOR_PULL_REQUEST_NUMBER" == "" ]]; then
29+
uv publish
30+
fi
31+
32+
artifacts:
33+
- path: dist/*.whl
34+
35+
test: off

0 commit comments

Comments
 (0)