-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add maturin setup and release workflow
- Loading branch information
Showing
5 changed files
with
218 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import re | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def main() -> int: | ||
if not (cargo_path := Path(os.getenv('CARGO_PATH', 'Cargo.toml'))).is_file(): | ||
print(f'✖ path "{cargo_path}" does not exist') | ||
return 1 | ||
|
||
if len(sys.argv) == 2: | ||
version = sys.argv[1] | ||
print(f'Found input version {version}') | ||
elif version := os.getenv('VERSION'): | ||
print(f'Found $VERSION {version}') | ||
elif version := os.getenv('GITHUB_REF'): | ||
print(f'Found $GITHUB_REF {version}') | ||
else: | ||
print(f'✖ "Version env variables not found') | ||
return 1 | ||
|
||
version = version.lower().replace('refs/tags/v', '').replace('a', '-alpha').replace('b', '-beta') | ||
print(f'writing version "{version}", to {cargo_path}') | ||
|
||
version_regex = re.compile('^version ?= ?".*"', re.M) | ||
cargo_content = cargo_path.read_text() | ||
if not version_regex.search(cargo_content): | ||
print(f'✖ {version_regex!r} not found in {cargo_path}') | ||
return 1 | ||
|
||
new_content = version_regex.sub(f'version = "{version}"', cargo_content) | ||
cargo_path.write_text(new_content) | ||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
.idea/ | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[build-system] | ||
requires = ["maturin>=0.14,<0.15"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "printf-log-formatter" | ||
description = "Convert logger f-strings and str.format syntax to printf-style strings" | ||
readme = "README.md" | ||
authors = [{ name = "Sondre Lillebø Gundersen", email = "[email protected]" }] | ||
license = { file = "LICENSE" } | ||
requires-python = ">=3.7" | ||
dependencies = [] | ||
keywords = ["linter", "formatter", "logging", "sentry"] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Rust", | ||
] | ||
|
||
[project.urls] | ||
Repository = "https://github.com/sondrelg/printf-log-formatter" | ||
Changelog = "https://github.com/sondrelg/printf-log-formatter/releases" |