3 Commits

Author SHA1 Message Date
1ac724603a Ignore OpenCode state directory
All checks were successful
CI / lint (push) Successful in 13s
CI / test (3.12) (push) Successful in -32s
CI / test (3.14) (push) Successful in -30s
CI / typecheck (push) Successful in -30s
CI / test (3.13) (push) Successful in -31s
2026-04-03 00:43:10 -07:00
907b911e95 Add release workflow and expand Python support matrix 2026-04-03 00:43:02 -07:00
383447d050 Add GitHub Actions CI workflow 2026-04-02 21:23:38 -07:00
4 changed files with 192 additions and 2 deletions

64
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: uv sync --locked
- name: Run ruff check
run: uv run ruff check src/ tests/
- name: Run ruff format check
run: uv run ruff format --check src/ tests/
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: uv sync --locked
- name: Run mypy
run: uv run mypy src/
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync --locked
- name: Run tests with coverage
run: uv run pytest --cov=rp --cov-report=term-missing

124
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,124 @@
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync --locked
- name: Run release checks
run: |
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
uv run mypy src/
uv run pytest --tb=short -q
release:
runs-on: ubuntu-latest
needs: checks
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"
enable-cache: true
- name: Install dependencies
run: uv sync --locked
- name: Validate release version
run: |
package_version="$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)"
module_version="$(grep '^__version__ = ' src/rp/__init__.py | cut -d '"' -f 2)"
expected_tag="v${package_version}"
if [ "$package_version" != "$module_version" ]; then
printf 'Version mismatch: pyproject.toml=%s src/rp/__init__.py=%s\n' "$package_version" "$module_version"
exit 1
fi
if [ "${{ github.ref_name }}" != "$expected_tag" ]; then
printf 'Tag %s does not match package version %s\n' "${{ github.ref_name }}" "$expected_tag"
exit 1
fi
- name: Build release artifacts
run: |
rm -rf dist
uv build
cd dist
sha256sum *.tar.gz *.whl > SHA256SUMS
- name: Generate release notes
run: |
tag="${{ github.ref_name }}"
release_target="${tag}^"
previous_tag="$(git tag --list 'v*' --sort=-version:refname | awk -v tag="$tag" '$0 == tag { found = 1; next } found { print; exit }')"
if ! git rev-parse --verify "$release_target" >/dev/null 2>&1; then
release_target="$tag"
fi
{
printf '# %s\n\n' "$tag"
if [ -n "$previous_tag" ]; then
printf '## Changes since %s\n\n' "$previous_tag"
git log --no-merges --pretty='- %s (%h)' "${previous_tag}..${release_target}"
else
printf '## Changes\n\n'
git log --no-merges --pretty='- %s (%h)' "$release_target"
fi
} > release-notes.md
- name: Create GitHub release
if: ${{ github.server_url == 'https://github.com' }}
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
body_path: release-notes.md
files: |
dist/*.tar.gz
dist/*.whl
dist/SHA256SUMS
- name: Create Gitea release
if: ${{ github.server_url == 'https://gitea.yunxiao.xyz' }}
uses: akkuman/gitea-release-action@v1
env:
NODE_OPTIONS: --experimental-fetch
with:
server_url: https://gitea.yunxiao.xyz
token: ${{ secrets.RELEASE_TOKEN_GITEA }}
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
body_path: release-notes.md
files: |
dist/*.tar.gz
dist/*.whl
dist/SHA256SUMS

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ build/
.pytest_cache/
.coverage
.env
.opencode/state

View File

@@ -16,6 +16,7 @@ classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Utilities",
"Typing :: Typed",
]
@@ -29,8 +30,8 @@ dependencies = [
rp = "rp.cli:app"
[project.urls]
Homepage = "https://github.com/yunxiaoxu/rich-viewer"
Repository = "https://github.com/yunxiaoxu/rich-viewer"
Homepage = "https://gitea.yunxiao.xyz/YunxiaoXu/rich-print"
Repository = "https://gitea.yunxiao.xyz/YunxiaoXu/rich-print.git"
[dependency-groups]
dev = [