Skip to content

Commit 779ef59

Browse files
committed
chore: add publish
1 parent 510237c commit 779ef59

File tree

3 files changed

+223
-24
lines changed

3 files changed

+223
-24
lines changed

.github/workflows/ci.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths-ignore:
7+
- "README.md"
8+
- "docs/**"
9+
- "*.md"
10+
pull_request:
11+
branches: ["main"]
12+
paths-ignore:
13+
- "README.md"
14+
- "docs/**"
15+
- "*.md"
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
lint-and-format:
23+
name: Code Quality & Linting
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v6
35+
with:
36+
enable-cache: true
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.13"
42+
43+
- name: Install packages
44+
run: uv sync --dev --locked
45+
46+
- name: Cache pre-commit hooks
47+
uses: actions/cache@v4
48+
with:
49+
path: ~/.cache/pre-commit
50+
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
51+
restore-keys: |
52+
pre-commit-${{ runner.os }}-
53+
54+
- name: Install pre-commit hooks
55+
run: uv run pre-commit run --all-files --show-diff-on-failure
56+
57+
test:
58+
name: Test Python ${{ matrix.python-version }}
59+
runs-on: ubuntu-latest
60+
timeout-minutes: 15
61+
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
python-version: ["3.11", "3.12", "3.13"]
66+
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
71+
- name: Install uv
72+
uses: astral-sh/setup-uv@v6
73+
with:
74+
enable-cache: true
75+
76+
- name: Set up Python ${{ matrix.python-version }}
77+
uses: actions/setup-python@v5
78+
with:
79+
python-version: ${{ matrix.python-version }}
80+
81+
- name: Install packages
82+
run: uv sync --dev --locked
83+
84+
- name: Run tests with coverage
85+
run: |
86+
uv run coverage run -m pytest
87+
uv run coverage xml -o coverage.xml
88+
uv run coverage report -m
89+
90+
- name: Upload coverage to Codecov
91+
uses: codecov/codecov-action@v5
92+
if: always()
93+
with:
94+
token: ${{ secrets.CODECOV_TOKEN }}
95+
files : ./coverage.xml
96+
flags: unittests
97+
name: codecov-python-${{ matrix.python-version }}
98+
fail_ci_if_error: false
99+
100+
all-checks:
101+
name: All Checks Passed
102+
runs-on: ubuntu-latest
103+
needs: [lint-and-format, test]
104+
if: always()
105+
106+
steps:
107+
- name: Check all jobs
108+
run: |
109+
if [[ "${{ needs.lint-and-format.result }}" != "success" ||
110+
"${{ needs.test.result }}" != "success" ]]; then
111+
echo "One or more checks failed"
112+
exit 1
113+
fi
114+
echo "All checks passed successfully"

.github/workflows/release.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
types: [completed]
7+
branches: ["main"]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}
18+
permissions:
19+
contents: write
20+
outputs:
21+
skipped: ${{ steps.changelog.outputs.skipped }}
22+
tag: ${{ steps.changelog.outputs.tag }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Conventional Changelog Action
28+
id: changelog
29+
uses: TriPSs/conventional-changelog-action@v6
30+
with:
31+
github-token: ${{ secrets.github_token }}
32+
skip-commit: true
33+
skip-tag: true
34+
version-file: "pyproject.toml"
35+
version-path: "project.version"
36+
preset: "conventionalcommits"
37+
release-count: 0
38+
tag-prefix: "v"
39+
output-file: "false"
40+
41+
- name: Set version as environment variable
42+
run: echo "VERSION=${{ steps.changelog.outputs.version }}" >> $GITHUB_ENV
43+
44+
- name: Update version in pyproject.toml
45+
run: sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
46+
47+
- name: Update version in Python file
48+
run: sed -i "s/__version__ = [\"'].*[\"']/__version__ = '$VERSION'/" pixiq/__init__.py
49+
50+
- name: Commit all changes together
51+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
52+
run: |
53+
git config user.name "github-actions[bot]"
54+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
55+
git add pyproject.toml pixiq/__init__.py
56+
git diff --cached --quiet || git commit -m "chore(release): v$VERSION [skip ci]"
57+
git tag -f "v$VERSION"
58+
git push
59+
git push --force origin "v$VERSION"
60+
61+
- name: Create Release
62+
uses: softprops/action-gh-release@v2
63+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
64+
with:
65+
tag_name: ${{ steps.changelog.outputs.tag }}
66+
name: ${{ steps.changelog.outputs.tag }}
67+
body: ${{ steps.changelog.outputs.clean_changelog }}
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
70+
build-and-publish:
71+
name: Build & Publish
72+
runs-on: ubuntu-latest
73+
needs: release
74+
if: ${{ needs.release.outputs.skipped == 'false' }}
75+
permissions:
76+
contents: read
77+
steps:
78+
- name: Checkout exact release tag
79+
uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
ref: ${{ needs.release.outputs.tag }}
83+
84+
- name: Install uv
85+
uses: astral-sh/setup-uv@v6
86+
with:
87+
enable-cache: true
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version-file: "pyproject.toml"
93+
94+
- name: Install packages
95+
run: uv sync --no-dev
96+
97+
- name: Build package
98+
run: uv build
99+
100+
- name: Publish to PyPI
101+
run: |
102+
if [ -n "${{ secrets.PYPI_API_TOKEN }}" ]; then
103+
uv publish --token "${{ secrets.PYPI_API_TOKEN }}"
104+
else
105+
echo "No PyPI token provided, skipping publish."
106+
fi

uv.lock

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

0 commit comments

Comments
 (0)