Skip to content

Commit

Permalink
.ci and appveyor.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
InesaFitsner committed Jan 8, 2025
1 parent cb53992 commit 9b5d4f8
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .ci/patch_pubspec_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
import pathlib
import sys

import yaml

if len(sys.argv) < 3:
print("Specify pubspec.yaml file and version to patch")
sys.exit(1)

current_dir = pathlib.Path(os.getcwd())
pubspec_path = current_dir.joinpath(current_dir, sys.argv[1])
ver = sys.argv[2]
print(f"Patching pubspec.yaml file {pubspec_path} with {ver}")

dependencies = [
"flet",
]

with open(pubspec_path, "r") as f:
data = yaml.safe_load(f)

# patch version
data["version"] = ver

with open(pubspec_path, "w") as file:
yaml.dump(data, file, sort_keys=False)
25 changes: 25 additions & 0 deletions .ci/patch_toml_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import pathlib
import sys

import tomlkit

if len(sys.argv) < 3:
print("Specify toml file and version to patch")
sys.exit(1)

current_dir = pathlib.Path(os.getcwd())
toml_path = current_dir.joinpath(current_dir, sys.argv[1])
ver = sys.argv[2]
print(f"Patching TOML file {toml_path} to {ver}")

# read
with open(toml_path, "r") as f:
t = tomlkit.parse(f.read())

# patch version
t["project"]["version"] = ver

# save
with open(toml_path, "w") as f:
f.write(tomlkit.dumps(t))
15 changes: 15 additions & 0 deletions .ci/update_build_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if [ -n "$APPVEYOR_REPO_TAG_NAME" ]; then
export PKG_VER="${APPVEYOR_REPO_TAG_NAME#v}" # Remove the 'v' prefix
export BUILD_VER="$PKG_VER"
else
# Get the latest Git tag and handle missing tags gracefully
cv=$(git describe --abbrev=0 2>/dev/null || echo "v0.0.0") # Default to v1.0.0 if no tag
cv=${cv#v} # Remove the 'v' prefix if present
major=$(echo "$cv" | cut -d. -f1)
minor=$(echo "$cv" | cut -d. -f2)
minor=$((minor + 1))
export PKG_VER="${major}.${minor}.0"
export BUILD_VER="${PKG_VER}+${APPVEYOR_BUILD_NUMBER}"
fi
export PYPI_VER="${BUILD_VER/+/.dev}"
appveyor UpdateBuild -Version $BUILD_VER
34 changes: 34 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
image: ubuntu

version: '0.1.{build}'

environment:
UV_PUBLISH_TOKEN:
secure: 174ncAbF5IjSIkmioPt62jeSnzmTlRNchUkE4QdjDWH8xK1olYtySXLJpo2q95HcP7lWJky1hv4APESiRRHnBWoY0XRFafzM/mbCDMzG1tZXiXZmpP1qzHAtRP2QSCIg18xh1TMktraUdTi7sbJnjjRhqzgbW1k0kLBxKw79MPFBhYQ/TiGcmaYWZbWVZNY3HCUCb6Dt7bG1OE2Ul9rD1gvs55xwO9Oq9FOVA1VnMYw=

stack:
- python 3.12

install:
- source .ci/update_build_version.sh
- python --version
- python -m ensurepip --upgrade
- pip3 install --upgrade tomlkit pyyaml
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH=$HOME/.local/bin:$PATH

build_script:
- python .ci/patch_toml_version.py pyproject.toml $PYPI_VER
- python .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER
- uv build

deploy_script:
- sh: |
if [[ ("$APPVEYOR_REPO_BRANCH" == "main" || "$APPVEYOR_REPO_TAG_NAME" != "") && "$APPVEYOR_PULL_REQUEST_NUMBER" == "" ]]; then
uv publish
fi
artifacts:
- path: dist/*.whl

test: off

0 comments on commit 9b5d4f8

Please sign in to comment.