Skip to content

Commit 51fc09d

Browse files
committed
ci: replace Appveyor with GitHub actions
1 parent 2a56423 commit 51fc09d

File tree

6 files changed

+134
-76
lines changed

6 files changed

+134
-76
lines changed

.ci/patch_toml_version.py

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

.ci/update_build_version.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.
File renamed without changes.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# ------------------------------------------------------------------------------
5+
# This script determines the version numbers used in builds and releases.
6+
#
7+
# It sets three environment variables:
8+
# - PKG_VER → The package version (semantic version).
9+
# - BUILD_VER → The build identifier (may include build number).
10+
# - PYPI_VER → A PyPI-compatible version string for publishing.
11+
#
12+
# Behavior:
13+
# - On a tagged commit (e.g. "v1.2.3"), it uses that tag as the version.
14+
# - On an untagged commit, it generates a "next dev version" by:
15+
# • Taking the latest tag (default v0.0.0 if none).
16+
# • Incrementing the minor version.
17+
# • Appending "+<run number>".
18+
# - PYPI_VER is derived from BUILD_VER by replacing "+" with ".dev".
19+
#
20+
# This ensures that:
21+
# - Release builds (tags) get clean versions like "1.2.3".
22+
# - Development builds get versions like "1.3.0+45" (PyPI: "1.3.0.dev45").
23+
# ------------------------------------------------------------------------------
24+
25+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
26+
# -------------------------------------------------------------
27+
# Case 1: This build is triggered by a Git tag
28+
# -------------------------------------------------------------
29+
# Extract the tag name (strip "refs/tags/")
30+
tag="${GITHUB_REF#refs/tags/}"
31+
# Remove leading "v" if present (e.g. "v1.2.3" → "1.2.3")
32+
export PKG_VER="${tag#v}"
33+
# For tagged releases, BUILD_VER is the same as PKG_VER
34+
export BUILD_VER="$PKG_VER"
35+
else
36+
# -------------------------------------------------------------
37+
# Case 2: This is not a tagged build (e.g. main branch commit)
38+
# -------------------------------------------------------------
39+
# Get the latest tag, or fall back to "v0.0.0" if none exist
40+
cv=$(git describe --abbrev=0 2>/dev/null || echo "v0.0.0")
41+
# Remove leading "v" if present
42+
cv=${cv#v}
43+
44+
# Split into major/minor components
45+
major=$(echo "$cv" | cut -d. -f1)
46+
minor=$(echo "$cv" | cut -d. -f2)
47+
48+
# Increment the minor version (e.g. "1.2" → "1.3")
49+
minor=$((minor + 1))
50+
51+
# Construct the package version: <major>.<minor>.0
52+
export PKG_VER="${major}.${minor}.0"
53+
54+
# Append the GitHub Actions run number for uniqueness
55+
export BUILD_VER="${PKG_VER}+$((GITHUB_RUN_NUMBER + 500))"
56+
fi
57+
58+
# -------------------------------------------------------------
59+
# Derive PyPI-compatible version
60+
# PyPI does not accept "+" in versions, so replace with ".dev"
61+
# Example: "1.3.0+45" → "1.3.0.dev45"
62+
# -------------------------------------------------------------
63+
export PYPI_VER="${BUILD_VER/+/.dev}"
64+
65+
# Print values for debugging in logs
66+
echo "PKG_VER=$PKG_VER"
67+
echo "BUILD_VER=$BUILD_VER"
68+
echo "PYPI_VER=$PYPI_VER"
69+
70+
# Export values as environment variables
71+
echo "PKG_VER=$PKG_VER" >> $GITHUB_ENV
72+
echo "BUILD_VER=$BUILD_VER" >> $GITHUB_ENV
73+
echo "PYPI_VER=$PYPI_VER" >> $GITHUB_ENV

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Build & Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # match all branches
7+
tags:
8+
- '*' # match all tags
9+
pull_request:
10+
workflow_dispatch:
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
jobs:
17+
build:
18+
name: Publish flet-permission-handler package
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # fetch all history
26+
fetch-tags: true # ensure tags are available
27+
28+
- name: Setup uv
29+
uses: astral-sh/setup-uv@v6
30+
31+
- name: Patch versions
32+
run: |
33+
source .github/scripts/update_build_version.sh
34+
uv version $PYPI_VER
35+
uv run .github/scripts/patch_pubspec_version.py src/flutter/*/pubspec.yaml $PKG_VER
36+
37+
- name: Setup Flutter
38+
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
39+
with:
40+
path: '.fvmrc'
41+
cache: true
42+
43+
- name: Analyze Flutter package
44+
run: |
45+
cd src/flutter/*
46+
dart pub get
47+
dart analyze
48+
cd -
49+
50+
- name: Build Python package
51+
run: uv build
52+
53+
- name: Upload build artifacts
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: dist
57+
path: dist/*.whl
58+
59+
- name: Publish Python package
60+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
61+
run: uv publish

appveyor.yml

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

0 commit comments

Comments
 (0)