From 63b5b561f543f60afbc206334dc63b2a7035f1ec Mon Sep 17 00:00:00 2001 From: mathleur Date: Fri, 17 Oct 2025 15:52:57 +0200 Subject: [PATCH 01/17] add cd that updates versions in python and rust --- .github/workflows/cd.yml | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..9146158 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,90 @@ +name: Auto Release (Rust + Python) + +on: + workflow_dispatch: + inputs: + bump: + description: "Version bump type" + required: true + default: "patch" + type: choice + options: + - patch + - minor + - major + + push: + branches: [main, develop] + +permissions: + contents: write + id-token: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install tools + run: | + pip install tomlkit semver + sudo apt-get update && sudo apt-get install -y jq + + - name: Get current version + id: get_version + run: | + current=$(grep '^version' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/') + echo "current=$current" >> $GITHUB_OUTPUT + echo "Current version: $current" + + - name: Bump version + id: bump + run: | + current=${{ steps.get_version.outputs.current }} + bump_type=${{ github.event.inputs.bump || 'patch' }} + new=$(python -c "import semver; print(semver.VersionInfo.parse('$current').bump_$bump_type())") + echo "new=$new" >> $GITHUB_OUTPUT + echo "Bumped version: $new" + + - name: Update Cargo.toml + run: | + version=${{ steps.bump.outputs.new }} + sed -i "s/^version = \".*\"/version = \"$version\"/" Cargo.toml + + - name: Sync version to pyproject.toml + run: | + version=${{ steps.bump.outputs.new }} + python - < Date: Fri, 17 Oct 2025 15:58:43 +0200 Subject: [PATCH 02/17] update version workflow --- .github/workflows/{cd.yml => update_version.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{cd.yml => update_version.yml} (96%) diff --git a/.github/workflows/cd.yml b/.github/workflows/update_version.yml similarity index 96% rename from .github/workflows/cd.yml rename to .github/workflows/update_version.yml index 9146158..5ae0a8e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/update_version.yml @@ -83,8 +83,8 @@ jobs: git push origin HEAD:main git push origin "v$version" - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + # - name: Publish to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 # - name: Publish to crates.io # run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} From 37821dd5713fe2a40a847add45aab4a398187ba5 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 11:46:14 +0200 Subject: [PATCH 03/17] update version update workflow --- .github/workflows/update_version.yml | 101 ++++++++++----------------- 1 file changed, 35 insertions(+), 66 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 5ae0a8e..2578186 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -1,90 +1,59 @@ -name: Auto Release (Rust + Python) +name: Release via GitHub Tag (with dev versions) on: - workflow_dispatch: - inputs: - bump: - description: "Version bump type" - required: true - default: "patch" - type: choice - options: - - patch - - minor - - major - push: - branches: [main, develop] - -permissions: - contents: write - id-token: write + tags: + - "**" jobs: - release: + publish: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Set up Python + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: '3.11' - name: Install tools run: | - pip install tomlkit semver - sudo apt-get update && sudo apt-get install -y jq - - - name: Get current version - id: get_version - run: | - current=$(grep '^version' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/') - echo "current=$current" >> $GITHUB_OUTPUT - echo "Current version: $current" + cargo install cargo-release --locked + pip install maturin tomlkit semver - - name: Bump version - id: bump + - name: Extract version from tag + id: version run: | - current=${{ steps.get_version.outputs.current }} - bump_type=${{ github.event.inputs.bump || 'patch' }} - new=$(python -c "import semver; print(semver.VersionInfo.parse('$current').bump_$bump_type())") - echo "new=$new" >> $GITHUB_OUTPUT - echo "Bumped version: $new" + TAG=${GITHUB_REF_NAME} + VERSION=${TAG#v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Detected version: $VERSION" - - name: Update Cargo.toml + - name: Set release version run: | - version=${{ steps.bump.outputs.new }} - sed -i "s/^version = \".*\"/version = \"$version\"/" Cargo.toml - - - name: Sync version to pyproject.toml - run: | - version=${{ steps.bump.outputs.new }} - python - < Date: Mon, 20 Oct 2025 11:51:14 +0200 Subject: [PATCH 04/17] remove unnecessary python v update --- .github/workflows/update_version.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 2578186..d67065c 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -41,14 +41,6 @@ jobs: VERSION=${{ steps.version.outputs.version }} echo "Setting release version $VERSION" cargo set-version $VERSION - python - <<'PYCODE' - import tomlkit - from pathlib import Path - path = Path("pyproject.toml") - data = tomlkit.parse(path.read_text()) - data["project"]["version"] = "${{ steps.version.outputs.version }}" - path.write_text(tomlkit.dumps(data)) - PYCODE - name: Commit release version bump run: | From 0f97eb88f93ee5d66d9ec10aa4e65f4fdc36ec6a Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 12:01:40 +0200 Subject: [PATCH 05/17] install necessary cargo pkg --- .github/workflows/update_version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index d67065c..7f199f0 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -26,6 +26,7 @@ jobs: - name: Install tools run: | cargo install cargo-release --locked + cargo install cargo-set-version pip install maturin tomlkit semver - name: Extract version from tag From 7e7e75aaba2199b944a1670a0d231c2e14d10395 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 13:05:47 +0200 Subject: [PATCH 06/17] git pull before git push --- .github/workflows/update_version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 7f199f0..58be26d 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -47,6 +47,7 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + git pull origin git add Cargo.toml pyproject.toml git commit -m "chore: set release version v${{ steps.version.outputs.version }}" git push origin HEAD:main From 354da38883292976d90f46d182589dc06630ce64 Mon Sep 17 00:00:00 2001 From: Niall Oswald <79726292+NiallOswald@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:41:37 +0100 Subject: [PATCH 07/17] Fix/charshape constraint edge (#27) * fix: simplify boundary edge checks * fix: add missing constraint edge --- src/algorithms/simplify_charshape.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/algorithms/simplify_charshape.rs b/src/algorithms/simplify_charshape.rs index 6459124..43ea68c 100644 --- a/src/algorithms/simplify_charshape.rs +++ b/src/algorithms/simplify_charshape.rs @@ -92,27 +92,27 @@ fn characteristic_shape(orig: &Polygon, eps: T, max_len: usize) -> Polygon where T: GeoFloat + SpadeNum, { - let orig_len = orig.exterior().0.len(); - - if orig_len < 3 { + if orig.exterior().0.len() < 3 { return orig.clone(); } let eps_2 = eps * eps; // Construct Delaunay triangulation + let num_vertices = orig.exterior().0.len() - 1; + let vertices = orig .exterior_coords_iter() - .take(orig_len - 1) // duplicate points are removed + .take(num_vertices) // duplicate points are removed .map(|c| Point2::new(c.x, c.y)) .collect::>(); - let edges = (0..orig_len - 2) + let edges = (0..num_vertices) .map(|i| { if i == 0 { [vertices.len() - 1, i] } else { - [i, i + 1] + [i - 1, i] } }) .collect::>(); @@ -143,8 +143,7 @@ where continue; } - let [from, to] = largest.edge.vertices().map(|v| v.index()); - if (to == from + 1) || (from == to + 1) || (to + from + 2 == orig_len) { + if largest.edge.is_constraint_edge() { continue; } From a63390582622a85fa8d2f29a81a652f4156035e9 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 13:13:03 +0200 Subject: [PATCH 08/17] remove git pull --- .github/workflows/update_version.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 58be26d..7f199f0 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -47,7 +47,6 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git pull origin git add Cargo.toml pyproject.toml git commit -m "chore: set release version v${{ steps.version.outputs.version }}" git push origin HEAD:main From 81b54bfa54a556a421a38e7b1385095a86885b19 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 13:16:34 +0200 Subject: [PATCH 09/17] push commit to current branch --- .github/workflows/update_version.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 7f199f0..3eae3d3 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -29,6 +29,18 @@ jobs: cargo install cargo-set-version pip install maturin tomlkit semver + - name: Detect current branch + id: branch + run: | + if [ -n "${GITHUB_HEAD_REF}" ]; then + BRANCH="${GITHUB_HEAD_REF}" + else + # For releases or tags + BRANCH="${GITHUB_REF_NAME}" + fi + echo "branch=$BRANCH" >> $GITHUB_OUTPUT + echo "Detected branch: $BRANCH" + - name: Extract version from tag id: version run: | @@ -49,4 +61,4 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" git add Cargo.toml pyproject.toml git commit -m "chore: set release version v${{ steps.version.outputs.version }}" - git push origin HEAD:main + git push origin HEAD:$BRANCH From f38f4e11b27f2935bb8448a5920d49f3976ef997 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 13:18:10 +0200 Subject: [PATCH 10/17] review comments --- .github/workflows/update_version.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 3eae3d3..c00df91 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -25,9 +25,7 @@ jobs: - name: Install tools run: | - cargo install cargo-release --locked cargo install cargo-set-version - pip install maturin tomlkit semver - name: Detect current branch id: branch @@ -59,6 +57,6 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add Cargo.toml pyproject.toml + git add Cargo.toml git commit -m "chore: set release version v${{ steps.version.outputs.version }}" git push origin HEAD:$BRANCH From 8c6cc9bf38e932fea3731b77d139666afc160a10 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 13:22:02 +0200 Subject: [PATCH 11/17] find current branch --- .github/workflows/update_version.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index c00df91..95aa0f8 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -18,11 +18,6 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Install Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Install tools run: | cargo install cargo-set-version @@ -38,6 +33,8 @@ jobs: fi echo "branch=$BRANCH" >> $GITHUB_OUTPUT echo "Detected branch: $BRANCH" + BRANCH=$(git branch --show-current) + echo "Detected branch: $BRANCH" - name: Extract version from tag id: version From eefa0a59e8661407fc0c359a10c92d09ffe040e5 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 15:06:05 +0200 Subject: [PATCH 12/17] try update branch from which commit was made --- .github/workflows/update_version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 95aa0f8..490d556 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -34,6 +34,7 @@ jobs: echo "branch=$BRANCH" >> $GITHUB_OUTPUT echo "Detected branch: $BRANCH" BRANCH=$(git branch --show-current) + BRANCH="${{ github.event.release.target_commitish }}" echo "Detected branch: $BRANCH" - name: Extract version from tag From cb2baecc2b4720c9d2120902884caca2ece7ea93 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 15:09:44 +0200 Subject: [PATCH 13/17] fix to run on release --- .github/workflows/update_version.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 490d556..4a2a21b 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -1,9 +1,8 @@ name: Release via GitHub Tag (with dev versions) on: - push: - tags: - - "**" + release: + types: [published] jobs: publish: From fd2d83d23883743a942b4d6ae059cb564786d279 Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 15:19:07 +0200 Subject: [PATCH 14/17] update branch --- .github/workflows/update_version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 4a2a21b..3973644 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -54,6 +54,7 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + BRANCH="${{ github.event.release.target_commitish }}" git add Cargo.toml git commit -m "chore: set release version v${{ steps.version.outputs.version }}" git push origin HEAD:$BRANCH From 0e2ba91762afd896fad38a6ac7e6fc3f00f365d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 20 Oct 2025 13:21:00 +0000 Subject: [PATCH 15/17] chore: set release version v0.0.1-test --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 63555d3..8c1a7cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polyshell" -version = "0.1.0" +version = "0.0.1-test" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 18f0669d47ec95efb8a725780c989453b0aa519e Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 20 Oct 2025 15:28:14 +0200 Subject: [PATCH 16/17] update tag to right commit --- .github/workflows/update_version.yml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml index 3973644..fc261c2 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version.yml @@ -21,21 +21,6 @@ jobs: run: | cargo install cargo-set-version - - name: Detect current branch - id: branch - run: | - if [ -n "${GITHUB_HEAD_REF}" ]; then - BRANCH="${GITHUB_HEAD_REF}" - else - # For releases or tags - BRANCH="${GITHUB_REF_NAME}" - fi - echo "branch=$BRANCH" >> $GITHUB_OUTPUT - echo "Detected branch: $BRANCH" - BRANCH=$(git branch --show-current) - BRANCH="${{ github.event.release.target_commitish }}" - echo "Detected branch: $BRANCH" - - name: Extract version from tag id: version run: | @@ -58,3 +43,9 @@ jobs: git add Cargo.toml git commit -m "chore: set release version v${{ steps.version.outputs.version }}" git push origin HEAD:$BRANCH + + - name: Move release tag to new commit + run: | + TAG=${{ github.event.release.tag_name }} + git tag -fa "$TAG" -m "Release $TAG (after version bump)" + git push origin "$TAG" --force From 6ac145266c4df4218fac7234a132ea7de2d7e360 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 20 Oct 2025 13:30:27 +0000 Subject: [PATCH 17/17] chore: set release version v0.0.2-test --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8c1a7cf..d019d78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polyshell" -version = "0.0.1-test" +version = "0.0.2-test" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html