Skip to content

Commit 12bb5f5

Browse files
committed
chore: github action
1 parent 688a508 commit 12bb5f5

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

.github/workflows/lint.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "**.py"
8+
- ".github/workflows/lint.yaml"
9+
- "pyproject.toml"
10+
- "ruff.toml"
11+
- "pyrightconfig.json"
12+
- ".pre-commit-config.yaml"
13+
pull_request:
14+
branches: [main]
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
env:
20+
PYTHON_VERSION: "3.10"
21+
UV_CACHE_DIR: /tmp/.uv-cache
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up uv
27+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
28+
29+
- name: Set up Python
30+
id: setup-python
31+
run: |
32+
uv python install ${{ env.PYTHON_VERSION }}
33+
uv python pin ${{ env.PYTHON_VERSION }}
34+
uv lock
35+
PY=$(uv run python -VV | shasum -a 256 | cut -d' ' -f1)
36+
echo PY: $PY
37+
echo "PY=$PY" >> "$GITHUB_OUTPUT"
38+
39+
- name: Restore uv cache
40+
uses: actions/cache@v4
41+
id: uv-cache
42+
with:
43+
path: ${{ env.UV_CACHE_DIR }}
44+
key: uv-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('uv.lock') }}
45+
restore-keys: |
46+
uv-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('uv.lock') }}
47+
uv-${{ steps.setup-python.outputs.PY }}
48+
49+
- name: Install dependencies
50+
if: steps.uv-cache.outputs.cache-hit != 'true'
51+
run: uv sync
52+
53+
- name: Restore pre-commit cache
54+
uses: actions/cache@v4
55+
with:
56+
path: ~/.cache/pre-commit
57+
key: pre-commit-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('.pre-commit-config.yaml') }}
58+
59+
- name: Code checks
60+
run: |
61+
uv run pre-commit run --all-files --show-diff-on-failure
62+
63+
- name: Minimize uv cache
64+
run: uv cache prune --ci

.github/workflows/publish.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
name: "Publish library"
11+
environment: publish
12+
permissions:
13+
id-token: write
14+
15+
steps:
16+
- name: Check out
17+
uses: actions/checkout@v4
18+
with:
19+
token: "${{ secrets.GITHUB_TOKEN }}"
20+
fetch-depth: 0
21+
22+
- name: Set up uv
23+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
24+
25+
- name: Build package
26+
run: |
27+
VERSION=$(uvx dunamai from any --no-metadata --style pep440).$(date +"%Y%m%d")
28+
echo $VERSION
29+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION
30+
uv build
31+
32+
- name: Publish package
33+
run: uv publish

0 commit comments

Comments
 (0)