From fee544b2ba2c6c3705fb3b4a7731d25e1babf90d Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Thu, 21 Aug 2025 22:12:31 +0200 Subject: [PATCH 1/2] ci: replace Appveyor with GitHub actions --- .ci/patch_toml_version.py | 29 -------- .ci/update_build_version.sh | 15 ---- .../scripts}/patch_pubspec_version.py | 0 .github/scripts/update_build_version.sh | 73 +++++++++++++++++++ .github/workflows/release.yml | 61 ++++++++++++++++ appveyor.yml | 32 -------- 6 files changed, 134 insertions(+), 76 deletions(-) delete mode 100644 .ci/patch_toml_version.py delete mode 100755 .ci/update_build_version.sh rename {.ci => .github/scripts}/patch_pubspec_version.py (100%) create mode 100755 .github/scripts/update_build_version.sh create mode 100644 .github/workflows/release.yml delete mode 100644 appveyor.yml diff --git a/.ci/patch_toml_version.py b/.ci/patch_toml_version.py deleted file mode 100644 index 9ee9900..0000000 --- a/.ci/patch_toml_version.py +++ /dev/null @@ -1,29 +0,0 @@ -# /// script -# dependencies = ["tomlkit"] -# /// - -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) 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)) diff --git a/.ci/update_build_version.sh b/.ci/update_build_version.sh deleted file mode 100755 index db4e214..0000000 --- a/.ci/update_build_version.sh +++ /dev/null @@ -1,15 +0,0 @@ -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 \ No newline at end of file diff --git a/.ci/patch_pubspec_version.py b/.github/scripts/patch_pubspec_version.py similarity index 100% rename from .ci/patch_pubspec_version.py rename to .github/scripts/patch_pubspec_version.py diff --git a/.github/scripts/update_build_version.sh b/.github/scripts/update_build_version.sh new file mode 100755 index 0000000..e5ce42a --- /dev/null +++ b/.github/scripts/update_build_version.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -e + +# ------------------------------------------------------------------------------ +# This script determines the version numbers used in builds and releases. +# +# It sets three environment variables: +# - PKG_VER → The package version (semantic version). +# - BUILD_VER → The build identifier (may include build number). +# - PYPI_VER → A PyPI-compatible version string for publishing. +# +# Behavior: +# - On a tagged commit (e.g. "v1.2.3"), it uses that tag as the version. +# - On an untagged commit, it generates a "next dev version" by: +# • Taking the latest tag (default v0.0.0 if none). +# • Incrementing the minor version. +# • Appending "+". +# - PYPI_VER is derived from BUILD_VER by replacing "+" with ".dev". +# +# This ensures that: +# - Release builds (tags) get clean versions like "1.2.3". +# - Development builds get versions like "1.3.0+45" (PyPI: "1.3.0.dev45"). +# ------------------------------------------------------------------------------ + +if [[ "$GITHUB_REF" == refs/tags/* ]]; then + # ------------------------------------------------------------- + # Case 1: This build is triggered by a Git tag + # ------------------------------------------------------------- + # Extract the tag name (strip "refs/tags/") + tag="${GITHUB_REF#refs/tags/}" + # Remove leading "v" if present (e.g. "v1.2.3" → "1.2.3") + export PKG_VER="${tag#v}" + # For tagged releases, BUILD_VER is the same as PKG_VER + export BUILD_VER="$PKG_VER" +else + # ------------------------------------------------------------- + # Case 2: This is not a tagged build (e.g. main branch commit) + # ------------------------------------------------------------- + # Get the latest tag, or fall back to "v0.0.0" if none exist + cv=$(git describe --abbrev=0 2>/dev/null || echo "v0.0.0") + # Remove leading "v" if present + cv=${cv#v} + + # Split into major/minor components + major=$(echo "$cv" | cut -d. -f1) + minor=$(echo "$cv" | cut -d. -f2) + + # Increment the minor version (e.g. "1.2" → "1.3") + minor=$((minor + 1)) + + # Construct the package version: ..0 + export PKG_VER="${major}.${minor}.0" + + # Append the GitHub Actions run number for uniqueness + export BUILD_VER="${PKG_VER}+$((GITHUB_RUN_NUMBER + 500))" +fi + +# ------------------------------------------------------------- +# Derive PyPI-compatible version +# PyPI does not accept "+" in versions, so replace with ".dev" +# Example: "1.3.0+45" → "1.3.0.dev45" +# ------------------------------------------------------------- +export PYPI_VER="${BUILD_VER/+/.dev}" + +# Print values for debugging in logs +echo "PKG_VER=$PKG_VER" +echo "BUILD_VER=$BUILD_VER" +echo "PYPI_VER=$PYPI_VER" + +# Export values as environment variables +echo "PKG_VER=$PKG_VER" >> $GITHUB_ENV +echo "BUILD_VER=$BUILD_VER" >> $GITHUB_ENV +echo "PYPI_VER=$PYPI_VER" >> $GITHUB_ENV diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..14e3e27 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Build & Publish + +on: + push: + branches: + - '**' # match all branches + tags: + - '*' # match all tags + pull_request: + workflow_dispatch: + +permissions: + id-token: write + contents: read + +jobs: + build: + name: Publish flet-webview package + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch all history + fetch-tags: true # ensure tags are available + + - name: Setup uv + uses: astral-sh/setup-uv@v6 + + - name: Patch versions + run: | + source .github/scripts/update_build_version.sh + uv version $PYPI_VER + uv run .github/scripts/patch_pubspec_version.py src/flutter/*/pubspec.yaml $PKG_VER + + - name: Setup Flutter + uses: kuhnroyal/flutter-fvm-config-action/setup@v3 + with: + path: '.fvmrc' + cache: true + + - name: Analyze Flutter package + run: | + cd src/flutter/* + dart pub get + dart analyze + cd - + + - name: Build Python package + run: uv build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/*.whl + + - name: Publish Python package + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + run: uv publish diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4ffd0f7..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -image: ubuntu - -version: '0.1.{build}' - -environment: - PYTHON_VERSION: 3.12 - UV_PUBLISH_TOKEN: - secure: 174ncAbF5IjSIkmioPt62jeSnzmTlRNchUkE4QdjDWH8xK1olYtySXLJpo2q95HcP7lWJky1hv4APESiRRHnBWoY0XRFafzM/mbCDMzG1tZXiXZmpP1qzHAtRP2QSCIg18xh1TMktraUdTi7sbJnjjRhqzgbW1k0kLBxKw79MPFBhYQ/TiGcmaYWZbWVZNY3HCUCb6Dt7bG1OE2Ul9rD1gvs55xwO9Oq9FOVA1VnMYw= - -install: -- source .ci/update_build_version.sh -- curl -LsSf https://astral.sh/uv/install.sh | sh -- export PATH="$HOME/.local/bin:$PATH" -- uv python install $PYTHON_VERSION -- uv python pin $PYTHON_VERSION - -build_script: -- uv run .ci/patch_toml_version.py pyproject.toml $PYPI_VER -- uv run .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER -- (cd src/flutter/* && dart pub get && dart analyze && cd -) -- 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 From 584964c584be2986a01beefb1190f5849df64071 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Thu, 21 Aug 2025 22:16:17 +0200 Subject: [PATCH 2/2] chore: add .fvmrc file with Flutter version 3.35.1 --- .fvmrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .fvmrc diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..214e658 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.35.1" +}