@@ -1077,8 +1077,8 @@ pub fn save_dependabot_file(project_info: &ProjectInfo) -> Result<()> {
10771077 Ok ( ( ) )
10781078}
10791079
1080- fn create_poetry_pypi_publish_file ( python_version : & str , include_docs : bool ) -> String {
1081- let mut yml = format ! (
1080+ fn create_poetry_pypi_publish_file ( python_version : & str ) -> String {
1081+ format ! (
10821082 r#"name: PyPi Publish
10831083on:
10841084 release:
@@ -1102,21 +1102,11 @@ jobs:
11021102 - name: Publish package
11031103 run: poetry publish --build
11041104"#
1105- ) ;
1106-
1107- if include_docs {
1108- yml. push_str (
1109- r#" - name: Deploy Docs
1110- run: poetry run mkdocs gh-deploy --force
1111- "# ,
1112- ) ;
1113- }
1114-
1115- yml
1105+ )
11161106}
11171107
1118- fn create_pypi_publish_file_pyo3 ( python_version : & str , include_docs : bool ) -> String {
1119- let mut yml = format ! (
1108+ fn create_pyo3_pypi_publish_file ( python_version : & str ) -> String {
1109+ format ! (
11201110 r#"name: PyPi Publish
11211111on:
11221112 release:
@@ -1223,21 +1213,11 @@ jobs:
12231213 command: upload
12241214 args: --non-interactive --skip-existing wheels-*/*
12251215"#
1226- ) ;
1227-
1228- if include_docs {
1229- yml. push_str (
1230- r#" - name: Deploy Docs
1231- run: mkdocs gh-deploy --force
1232- "# ,
1233- ) ;
1234- }
1235-
1236- yml
1216+ )
12371217}
12381218
1239- fn create_setuptools_pypi_publish_file ( python_version : & str , include_docs : bool ) -> String {
1240- let mut yml = format ! (
1219+ fn create_setuptools_pypi_publish_file ( python_version : & str ) -> String {
1220+ format ! (
12411221 r#"name: PyPi Publish
12421222on:
12431223 release:
@@ -1263,21 +1243,11 @@ jobs:
12631243 python -m build
12641244 twine upload dist/*
12651245"#
1266- ) ;
1267-
1268- if include_docs {
1269- yml. push_str (
1270- r#" - name: Deploy Docs
1271- run: mkdocs gh-deploy --force
1272- "# ,
1273- ) ;
1274- }
1275-
1276- yml
1246+ )
12771247}
12781248
1279- fn create_uv_pypi_publish_file ( python_version : & str , include_docs : bool ) -> String {
1280- let mut yml = format ! (
1249+ fn create_uv_pypi_publish_file ( python_version : & str ) -> String {
1250+ format ! (
12811251 r#"name: PyPi Publish
12821252on:
12831253 release:
@@ -1304,21 +1274,11 @@ jobs:
13041274 - name: Build and publish package
13051275 run: uv publish
13061276"#
1307- ) ;
1308-
1309- if include_docs {
1310- yml. push_str (
1311- r#" - name: Deploy Docs
1312- run: mkdocs gh-deploy --force
1313- "# ,
1314- ) ;
1315- }
1316-
1317- yml
1277+ )
13181278}
13191279
1320- fn create_pixi_pypi_publish_file ( python_version : & str , include_docs : bool ) -> String {
1321- let mut yml = format ! (
1280+ fn create_pixi_pypi_publish_file ( python_version : & str ) -> String {
1281+ format ! (
13221282 r#"name: PyPi Publish
13231283on:
13241284 release:
@@ -1340,40 +1300,160 @@ jobs:
13401300 pixi exec --spec python=="{python_version}.*" --spec python-build pyproject-build
13411301 pixi exec --spec python=="{python_version}.*" --spec twine twine upload dist/*
13421302"#
1343- ) ;
1344-
1345- if include_docs {
1346- yml. push_str (
1347- r#" - name: Deploy Docs
1348- run: pixi run run-deploy-docs
1349- "# ,
1350- ) ;
1351- }
1352-
1353- yml
1303+ )
13541304}
13551305
13561306pub fn save_pypi_publish_file ( project_info : & ProjectInfo ) -> Result < ( ) > {
13571307 let file_path = project_info
13581308 . base_dir ( )
13591309 . join ( ".github/workflows/pypi_publish.yml" ) ;
13601310 let content = match & project_info. project_manager {
1361- ProjectManager :: Maturin => {
1362- create_pypi_publish_file_pyo3 ( & project_info. python_version , project_info. include_docs )
1311+ ProjectManager :: Maturin => create_pyo3_pypi_publish_file ( & project_info. python_version ) ,
1312+ ProjectManager :: Poetry => create_poetry_pypi_publish_file ( & project_info. python_version ) ,
1313+ ProjectManager :: Setuptools => {
1314+ create_setuptools_pypi_publish_file ( & project_info. python_version )
13631315 }
1364- ProjectManager :: Poetry => {
1365- create_poetry_pypi_publish_file ( & project_info. python_version , project_info. include_docs )
1366- }
1367- ProjectManager :: Setuptools => create_setuptools_pypi_publish_file (
1368- & project_info. python_version ,
1369- project_info. include_docs ,
1370- ) ,
1371- ProjectManager :: Uv => {
1372- create_uv_pypi_publish_file ( & project_info. python_version , project_info. include_docs )
1316+ ProjectManager :: Uv => create_uv_pypi_publish_file ( & project_info. python_version ) ,
1317+ ProjectManager :: Pixi => create_pixi_pypi_publish_file ( & project_info. python_version ) ,
1318+ } ;
1319+
1320+ save_file_with_content ( & file_path, & content) ?;
1321+
1322+ Ok ( ( ) )
1323+ }
1324+
1325+ fn create_poetry_docs_publish_file ( python_version : & str ) -> String {
1326+ format ! (
1327+ r#"name: Docs Publish
1328+ on:
1329+ release:
1330+ types:
1331+ - published
1332+ jobs:
1333+ deploy:
1334+ runs-on: ubuntu-latest
1335+ steps:
1336+ - uses: actions/checkout@v4
1337+ - name: Install Poetry
1338+ run: pipx install poetry
1339+ - name: Set up Python
1340+ uses: actions/setup-python@v5
1341+ with:
1342+ python-version: "{python_version}"
1343+ cache: "poetry"
1344+ - name: Install Dependencies
1345+ run: |
1346+ poetry install
1347+ - name: Publish package
1348+ run: poetry run mkdocs gh-deploy --force
1349+ "#
1350+ )
1351+ }
1352+
1353+ fn create_setuptools_docs_publish_file ( python_version : & str ) -> String {
1354+ format ! (
1355+ r#"name: Docs Publish
1356+ on:
1357+ release:
1358+ types:
1359+ - published
1360+ jobs:
1361+ deploy:
1362+ runs-on: ubuntu-latest
1363+ steps:
1364+ - uses: actions/checkout@v4
1365+ - name: Set up Python
1366+ uses: actions/setup-python@v5
1367+ with:
1368+ python-version: "{python_version}"
1369+ cache: "pip"
1370+ - name: Install Dependencies
1371+ run: |
1372+ python -m pip install -U pip
1373+ python -m pip -r requirements-dev.txt
1374+ - name: Publish docs
1375+ run: mkdocs gh-deploy --force
1376+ "#
1377+ )
1378+ }
1379+
1380+ fn create_pixi_docs_publish_file ( python_version : & str ) -> String {
1381+ format ! (
1382+ r#"name: Docs Publish
1383+ on:
1384+ release:
1385+ types:
1386+ - published
1387+ jobs:
1388+ deploy:
1389+ runs-on: ubuntu-latest
1390+ steps:
1391+ - uses: actions/checkout@v4
1392+ - name: Install Pixi
1393+ uses: prefix-dev/[email protected] 1394+ with:
1395+ pixi-version: v0.30.0
1396+ - name: Set up Python
1397+ run: pixi add python=="{python_version}.*"
1398+ - name: Deploy Docs
1399+ run pixi run run-deploy-docs
1400+ "#
1401+ )
1402+ }
1403+
1404+ fn create_uv_docs_publish_file ( python_version : & str ) -> String {
1405+ format ! (
1406+ r#"name: Docs Publish
1407+ on:
1408+ release:
1409+ types:
1410+ - published
1411+ jobs:
1412+ deploy:
1413+ runs-on: ubuntu-latest
1414+ steps:
1415+ - uses: actions/checkout@v4
1416+ - name: Install uv
1417+ uses: astral-sh/setup-uv@v3
1418+ with:
1419+ enable-cache: true
1420+ - name: Set up Python
1421+ uses: actions/setup-python@v5
1422+ with:
1423+ python-version: "{python_version}"
1424+ - name: Install Dependencies
1425+ run: uv sync --frozen
1426+ - name: Deploy Docs
1427+ run: uv run mkdocs gh-deploy --force
1428+ "#
1429+ )
1430+ }
1431+
1432+ pub fn save_docs_publish_file ( project_info : & ProjectInfo ) -> Result < ( ) > {
1433+ let file_path = project_info
1434+ . base_dir ( )
1435+ . join ( ".github/workflows/docs_publish.yml" ) ;
1436+ let content = match & project_info. project_manager {
1437+ ProjectManager :: Maturin => {
1438+ if let Some ( pyo3_python_manager) = & project_info. pyo3_python_manager {
1439+ match pyo3_python_manager {
1440+ Pyo3PythonManager :: Setuptools => {
1441+ create_setuptools_docs_publish_file ( & project_info. python_version )
1442+ }
1443+ Pyo3PythonManager :: Uv => {
1444+ create_uv_docs_publish_file ( & project_info. python_version )
1445+ }
1446+ }
1447+ } else {
1448+ bail ! ( "No PyO3 Python project manager specified" ) ;
1449+ }
13731450 }
1374- ProjectManager :: Pixi => {
1375- create_pixi_pypi_publish_file ( & project_info. python_version , project_info. include_docs )
1451+ ProjectManager :: Poetry => create_poetry_docs_publish_file ( & project_info. python_version ) ,
1452+ ProjectManager :: Setuptools => {
1453+ create_setuptools_docs_publish_file ( & project_info. python_version )
13761454 }
1455+ ProjectManager :: Uv => create_uv_docs_publish_file ( & project_info. python_version ) ,
1456+ ProjectManager :: Pixi => create_pixi_docs_publish_file ( & project_info. python_version ) ,
13771457 } ;
13781458
13791459 save_file_with_content ( & file_path, & content) ?;
@@ -1901,15 +1981,15 @@ mod tests {
19011981 }
19021982
19031983 #[ test]
1904- fn test_save_pypi_publish_file_poetry_docs ( ) {
1984+ fn test_save_docs_publish_file_poetry ( ) {
19051985 let mut project_info = project_info_dummy ( ) ;
19061986 project_info. project_manager = ProjectManager :: Poetry ;
19071987 project_info. include_docs = true ;
19081988 project_info. docs_info = Some ( docs_info_dummy ( ) ) ;
19091989 let base = project_info. base_dir ( ) ;
19101990 create_dir_all ( base. join ( ".github/workflows" ) ) . unwrap ( ) ;
1911- let expected_file = base. join ( ".github/workflows/pypi_publish .yml" ) ;
1912- save_pypi_publish_file ( & project_info) . unwrap ( ) ;
1991+ let expected_file = base. join ( ".github/workflows/docs_publish .yml" ) ;
1992+ save_docs_publish_file ( & project_info) . unwrap ( ) ;
19131993
19141994 assert ! ( expected_file. is_file( ) ) ;
19151995
@@ -1935,15 +2015,15 @@ mod tests {
19352015 }
19362016
19372017 #[ test]
1938- fn test_save_pypi_publish_file_pyo3_docs ( ) {
2018+ fn test_save_docs_publish_file_pyo3 ( ) {
19392019 let mut project_info = project_info_dummy ( ) ;
19402020 project_info. project_manager = ProjectManager :: Maturin ;
19412021 project_info. include_docs = true ;
19422022 project_info. docs_info = Some ( docs_info_dummy ( ) ) ;
19432023 let base = project_info. base_dir ( ) ;
19442024 create_dir_all ( base. join ( ".github/workflows" ) ) . unwrap ( ) ;
1945- let expected_file = base. join ( ".github/workflows/pypi_publish .yml" ) ;
1946- save_pypi_publish_file ( & project_info) . unwrap ( ) ;
2025+ let expected_file = base. join ( ".github/workflows/docs_publish .yml" ) ;
2026+ save_docs_publish_file ( & project_info) . unwrap ( ) ;
19472027
19482028 assert ! ( expected_file. is_file( ) ) ;
19492029
@@ -1969,15 +2049,15 @@ mod tests {
19692049 }
19702050
19712051 #[ test]
1972- fn test_save_pypi_publish_file_setuptools_docs ( ) {
2052+ fn test_save_docs_publish_file_setuptools ( ) {
19732053 let mut project_info = project_info_dummy ( ) ;
19742054 project_info. project_manager = ProjectManager :: Setuptools ;
19752055 project_info. include_docs = true ;
19762056 project_info. docs_info = Some ( docs_info_dummy ( ) ) ;
19772057 let base = project_info. base_dir ( ) ;
19782058 create_dir_all ( base. join ( ".github/workflows" ) ) . unwrap ( ) ;
1979- let expected_file = base. join ( ".github/workflows/pypi_publish .yml" ) ;
1980- save_pypi_publish_file ( & project_info) . unwrap ( ) ;
2059+ let expected_file = base. join ( ".github/workflows/docs_publish .yml" ) ;
2060+ save_docs_publish_file ( & project_info) . unwrap ( ) ;
19812061
19822062 assert ! ( expected_file. is_file( ) ) ;
19832063
@@ -2003,15 +2083,15 @@ mod tests {
20032083 }
20042084
20052085 #[ test]
2006- fn test_save_pypi_publish_file_uv_docs ( ) {
2086+ fn test_save_docs_publish_file_uv ( ) {
20072087 let mut project_info = project_info_dummy ( ) ;
20082088 project_info. project_manager = ProjectManager :: Uv ;
20092089 project_info. include_docs = true ;
20102090 project_info. docs_info = Some ( docs_info_dummy ( ) ) ;
20112091 let base = project_info. base_dir ( ) ;
20122092 create_dir_all ( base. join ( ".github/workflows" ) ) . unwrap ( ) ;
2013- let expected_file = base. join ( ".github/workflows/pypi_publish .yml" ) ;
2014- save_pypi_publish_file ( & project_info) . unwrap ( ) ;
2093+ let expected_file = base. join ( ".github/workflows/docs_publish .yml" ) ;
2094+ save_docs_publish_file ( & project_info) . unwrap ( ) ;
20152095
20162096 assert ! ( expected_file. is_file( ) ) ;
20172097
@@ -2037,15 +2117,15 @@ mod tests {
20372117 }
20382118
20392119 #[ test]
2040- fn test_save_pypi_publish_file_pixi_docs ( ) {
2120+ fn test_save_docs_publish_file_pixi ( ) {
20412121 let mut project_info = project_info_dummy ( ) ;
20422122 project_info. project_manager = ProjectManager :: Pixi ;
20432123 project_info. include_docs = true ;
20442124 project_info. docs_info = Some ( docs_info_dummy ( ) ) ;
20452125 let base = project_info. base_dir ( ) ;
20462126 create_dir_all ( base. join ( ".github/workflows" ) ) . unwrap ( ) ;
2047- let expected_file = base. join ( ".github/workflows/pypi_publish .yml" ) ;
2048- save_pypi_publish_file ( & project_info) . unwrap ( ) ;
2127+ let expected_file = base. join ( ".github/workflows/docs_publish .yml" ) ;
2128+ save_docs_publish_file ( & project_info) . unwrap ( ) ;
20492129
20502130 assert ! ( expected_file. is_file( ) ) ;
20512131
0 commit comments