Add funding info and update workflows

Added a FUNDING.yml file to specify sponsorship details. Updated the CI workflow to include a new job for updating badges and improved PyPI version handling. Modified README badges and CLI to include a banner print function and adjusted version display.
This commit is contained in:
xixu-me committed 2025-05-30 12:01:34 +08:00
1 parent c26273fd79
commit 12fe2a8d5e
4 files changed
+67 -7

No files matched your search

+1
View File
@@ -0,0 +1 @@
custom: https://xi-xu.me/#sponsorships
+51 -1
View File
@@ -85,7 +85,7 @@ jobs:
name: pypi
url: https://pypi.org/p/tzst
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Download build artifacts
@@ -96,3 +96,53 @@ jobs:
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
update_badges:
needs: [build, publish]
if: always() && needs.build.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- name: Wait if this is after a publish
if: github.event_name == 'release' && github.event.action == 'published'
run: sleep 30
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Fetch PyPI version
id: pypi_version
run: |
pip install requests
python -c "
import requests, json
try:
data = requests.get('https://pypi.org/pypi/tzst/json').json()
version = data['info']['version']
print(f'PyPI version: {version}')
except Exception as e:
print(f'Error fetching version: {e}')
version = 'unknown'
print(f'::set-output name=version::{version}')
"
- name: Update README badge
run: |
echo "Updating PyPI badge with version: ${{ steps.pypi_version.outputs.version }}"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update badges [skip ci]"
file_pattern: README.md
branch: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
+5 -5
View File
@@ -2,10 +2,10 @@
A Python library for creating and manipulating `.tzst`/`.tar.zst` archives using Zstandard compression.
[![CI/CD](https://github.com/xixu-me/tzst/workflows/CI/CD/badge.svg)](https://github.com/xixu-me/tzst/actions)
[![PyPI version](https://badge.fury.io/py/tzst.svg)](https://badge.fury.io/py/tzst)
[![Python versions](https://img.shields.io/pypi/pyversions/tzst.svg)](https://pypi.org/project/tzst/)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![CI/CD](https://github.com/xixu-me/tzst/actions/workflows/ci.yml/badge.svg)](https://github.com/xixu-me/tzst/actions/workflows/ci.yml)
[![PyPI - Version](https://img.shields.io/pypi/v/tzst)](https://pypi.org/project/tzst/)
[![GitHub License](https://img.shields.io/github/license/xixu-me/tzst)](LICENSE)
[![Sponsor](https://img.shields.io/badge/Sponsor-violet)](https://xi-xu.me/#sponsorships)
## Features
@@ -30,7 +30,7 @@ pip install tzst
```bash
git clone https://github.com/xixu-me/tzst.git
cd tzst
pip install -e .
pip install .
```
### Development Installation
+10 -1
View File
@@ -10,6 +10,12 @@ from .core import create_archive, extract_archive, list_archive, test_archive
from .exceptions import TzstArchiveError, TzstDecompressionError
def print_banner() -> None:
"""Print the version and copyright banner."""
print()
print(f"tzst {__version__} : Copyright (c) 2025 Xi Xu")
def format_size(size: int) -> str:
"""Format file size in human-readable format."""
size_float = float(size)
@@ -240,7 +246,7 @@ Command Reference:
parser.add_argument(
"--version",
action="version",
version=f"tzst {__version__} : Copyright (c) 2025 Xi Xu",
version=f"tzst {__version__}",
)
subparsers = parser.add_subparsers(
@@ -313,6 +319,9 @@ Command Reference:
def main(argv: Optional[List[str]] = None) -> int:
"""Main entry point for the CLI."""
print_banner()
print()
parser = create_parser()
args = parser.parse_args(argv)