Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit 29eb217

Browse files
authored
v1(ci): Replace AppVeyor by GitHub Actions (#13)
* Rename .ci/patch_pubspec_version.py to .github/scripts/patch_pubspec_version.py * Rename .ci/patch_toml_version.py to .github/scripts/patch_toml_version.py * Rename .ci/update_build_version.sh to .github/scripts/update_build_version.sh * Create build-and-publish.yml * Update build-and-publish.yml * Update update_build_version.sh * Update build-and-publish.yml * Update build-and-publish.yml * Update update_build_version.sh * Update build-and-publish.yml * Update build-and-publish.yml * Delete .github/scripts/patch_toml_version.py * Update build-and-publish.yml * Update update_build_version.sh * Update build-and-publish.yml * Update update_build_version.sh * Rename build-and-publish.yml to release.yml * Update release.yml * Create .fvmrc * Update release.yml * Update release.yml * Update release.yml * Update release.yml
1 parent 86eaa0b commit 29eb217

6 files changed

Lines changed: 133 additions & 44 deletions

File tree

.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.

.fvmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"flutter": "3.35.1"
3+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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}"
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 for subsequent GitHub Actions steps
71+
# Anything written to $GITHUB_ENV becomes available as an env var
72+
echo "PKG_VER=$PKG_VER" >> $GITHUB_ENV
73+
echo "BUILD_VER=$BUILD_VER" >> $GITHUB_ENV
74+
echo "PYPI_VER=$PYPI_VER" >> $GITHUB_ENV

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)