Skip to content

Commit 9cf81db

Browse files
YaoerWuCopilot
andcommitted
release: 0.2.0
Co-authored-by: Copilot <copilot@github.com>
1 parent 2952ca3 commit 9cf81db

11 files changed

Lines changed: 102 additions & 124 deletions

File tree

.github/workflows/CI.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ name: CI
77

88
on:
99
push:
10-
branches:
11-
- main
12-
- master
10+
# branches:
11+
# - main
12+
# - master
1313
tags:
1414
- "*"
1515
pull_request:
@@ -191,6 +191,7 @@ jobs:
191191
release:
192192
name: Release
193193
runs-on: ubuntu-latest
194+
environment: pypi_api_token
194195
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name ==
195196
'workflow_dispatch' }}
196197
needs: [ linux, musllinux, windows, macos, sdist ]
@@ -207,19 +208,20 @@ jobs:
207208
uses: actions/attest-build-provenance@v3
208209
with:
209210
subject-path: "wheels-*/*"
210-
# - name: Install uv
211-
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
212-
# uses: astral-sh/setup-uv@v7
213-
# - name: Publish to PyPI
214-
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
215-
# run: uv publish 'wheels-*/*'
216-
- name: Create GitHub Release
217-
uses: softprops/action-gh-release@v2
218-
if: startsWith(github.ref, 'refs/tags/')
219-
with:
220-
# 同样使用通配符,确保抓取所有子文件夹里的 whl 和 sdist
221-
files: wheels-*/*
222-
generate_release_notes: true
211+
- name: Install uv
212+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
213+
uses: astral-sh/setup-uv@v7
214+
- name: Publish to PyPI
215+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
216+
run: uv publish 'wheels-*/*'
217+
218+
# - name: Create GitHub Release
219+
# uses: softprops/action-gh-release@v2
220+
# if: startsWith(github.ref, 'refs/tags/')
221+
# with:
222+
# # 同样使用通配符,确保抓取所有子文件夹里的 whl 和 sdist
223+
# files: wheels-*/*
224+
# generate_release_notes: true
223225
env:
224-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
225-
# UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
226+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
227+
UV_PUBLISH_TRUSTED_PUBLISHER: "true"

Cargo.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
[package]
2-
name = "image-autowsgrs"
3-
version = "0.1.0"
4-
edition = "2024"
51
[workspace]
6-
members = ["vessel-type", "python-bindings"]
2+
members = ["vessel_type", "python_bindings"]
3+
[workspace.package]
4+
version = "0.0.0"
5+
edition = "2024"
6+
7+
[package]
8+
name = "autowsgr_native"
9+
version.workspace = true
10+
edition.workspace = true
11+
712

813
[build-dependencies]
9-
vessel-type = { path = "./vessel-type" }
14+
vessel_type = { path = "./vessel_type" }
1015
strum = "0.28"
1116
image = "0.25"
1217

1318
[dependencies]
14-
vessel-type = { path = "./vessel-type" }
19+
vessel_type = { path = "./vessel_type" }
1520

1621
[dev-dependencies]
1722
image = "0.25"

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ requires = ["maturin>=1.0,<2.0"]
33
build-backend = "maturin"
44

55
[project]
6-
name = "image-autowsgrs"
7-
version = "0.2.0"
6+
name = "autowsgr_native"
7+
dynamic = ["version"]
88
description = "Image recognition library for AutoWSGR"
9-
requires-python = ">=3.8"
9+
requires-python = ">=3.12"
1010
dependencies = ["numpy>=1.24.4", "opencv-python>=4.13.0.92"]
1111

1212
[tool.maturin]

python-bindings/Cargo.toml

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

python_bindings/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "autowsgr_native_py"
3+
version.workspace = true
4+
edition.workspace = true
5+
6+
[lib]
7+
name = "autowsgr_native"
8+
crate-type = ["cdylib"]
9+
10+
[dependencies]
11+
pyo3 = { version = "0.28", features = ["extension-module", "abi3-py312"] }
12+
numpy = "0.28"
13+
autowsgr_native = { path = ".." }
14+
vessel_type = { path = "../vessel_type", features = ["pyo3"] }
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use pyo3::prelude::*;
44
use std::borrow::Cow;
55

66
#[pyo3::pymodule]
7-
mod image_autowsgrs {
7+
mod autowsgr_native {
88
use super::*;
9-
use ::image_autowsgrs::{
9+
use ::autowsgr_native::{
1010
WrappedPixels, image::BGRImage, recognize_enemy::character_image::CharacterImage,
1111
};
1212

@@ -38,7 +38,7 @@ mod image_autowsgrs {
3838
pixels: &pixels,
3939
};
4040
let bgr = BGRImage::from_wrapped_pixels(wrapped);
41-
Ok(::image_autowsgrs::locator::locate(&bgr))
41+
Ok(::autowsgr_native::locator::locate(&bgr))
4242
}
4343

4444
#[pyfunction]
@@ -47,8 +47,8 @@ mod image_autowsgrs {
4747
for img in &images {
4848
let shape = img.shape();
4949
let (height, width) = (shape[0], shape[1]);
50-
if height != ::image_autowsgrs::recognize_enemy::HEIGHT
51-
|| width != ::image_autowsgrs::recognize_enemy::WIDTH
50+
if height != ::autowsgr_native::recognize_enemy::HEIGHT
51+
|| width != ::autowsgr_native::recognize_enemy::WIDTH
5252
{
5353
return Err(PyValueError::new_err(format!(
5454
"expected grayscale image with shape (H, W), got shape {:?}",
@@ -68,7 +68,7 @@ mod image_autowsgrs {
6868
};
6969
char_images.push(CharacterImage::from_wrapped_pixels(wrapped));
7070
}
71-
let result = ::image_autowsgrs::recognize_enemy::recognize_enemy(&char_images);
71+
let result = ::autowsgr_native::recognize_enemy::recognize_enemy(&char_images);
7272
Ok(result
7373
.iter()
7474
.map(|vessel_type| vessel_type.as_english())
@@ -98,7 +98,7 @@ mod image_autowsgrs {
9898
pixels: &pixels,
9999
};
100100
let bgr = BGRImage::from_wrapped_pixels(wrapped);
101-
let result = ::image_autowsgrs::recognize_map::recognize_map(&bgr);
101+
let result = ::autowsgr_native::recognize_map::recognize_map(&bgr);
102102
Ok(result.to_string())
103103
}
104104
}

src/recognize_enemy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use vessel_type::VesselType;
77

88
pub const WIDTH: usize = 32;
99
pub const HEIGHT: usize = 16;
10-
const ENDWITH_巡: &[&str; 6] = &["CA", "CL", "CAV", "CLT", "CBG", "BC"];
10+
const ENDWITH_巡: &[&str; 6] = &["CA", "CL", "CAV", "CLT", "BG", "BC"];
1111
const ENDWITH_母: &[&str; 3] = &["CV", "AV", "CVL"];
1212
const STARTWITH_战: &[&str; 2] = &["BB", "BC"];
1313
const STARTWITH_轻: &[&str; 2] = &["CL", "CVL"];

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
2-
name = "vessel-type"
3-
version = "0.1.0"
4-
edition = "2024"
2+
name = "vessel_type"
3+
version.workspace = true
4+
edition.workspace = true
55

66
[dependencies]
77
strum = { version = "0.28", features = ["derive"] }

0 commit comments

Comments
 (0)