feat: restructure GitHub workflows; add CI workflow, update publish process, and remove obsolete test and lint workflows

This commit is contained in:
bohd4nx
2026-03-16 18:22:58 +02:00
parent 520153dfb1
commit f5d2e8490a
10 changed files with 152 additions and 83 deletions
+9
View File
@@ -8,3 +8,12 @@ updates:
open-pull-requests-limit: 5
labels:
- "dependencies"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 5
labels:
- "dependencies"
+50
View File
@@ -0,0 +1,50 @@
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v7.5.0
- run: uv pip install --system ".[dev]"
- run: ruff check .
- run: black --check . --target-version py312
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v7.5.0
- run: uv pip install --system ".[dev]"
- name: Write cookies.json
if: ${{ env.COOKIES_JSON != '' }}
run: echo "$COOKIES_JSON" > cookies.json
env:
COOKIES_JSON: ${{ secrets.COOKIES_JSON }}
- run: pytest
-31
View File
@@ -1,31 +0,0 @@
name: Lint
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
lint:
name: Lint & format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v7.5.0
- name: Install dev dependencies
run: uv pip install --system ".[dev]"
- name: Run ruff
run: ruff check .
- name: Run black
run: black --check . --target-version py312
+66 -15
View File
@@ -1,12 +1,44 @@
name: Publish to PyPI
name: Publish
on:
push:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [master]
jobs:
version-check:
name: Version Check
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.value }}
is-new: ${{ steps.tag.outputs.is-new }}
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Read version
id: version
run: |
value=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "value=$value" >> $GITHUB_OUTPUT
- name: Check tag
id: tag
run: |
if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.value }}" | grep -q .; then
echo "is-new=false" >> $GITHUB_OUTPUT
else
echo "is-new=true" >> $GITHUB_OUTPUT
fi
build:
name: Build
needs: version-check
if: needs.version-check.outputs.is-new == 'true'
runs-on: ubuntu-latest
steps:
@@ -16,23 +48,19 @@ jobs:
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v7.5.0
- uses: astral-sh/setup-uv@v7.5.0
- name: Build distribution
run: uv build
- run: uv build
- name: Upload artifacts
uses: actions/upload-artifact@v7
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/*
publish:
name: Publish
needs: build
name: Publish to PyPI
needs: [version-check, build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
environment:
name: pypi
url: https://pypi.org/project/pyfragment/
@@ -40,11 +68,34 @@ jobs:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v8.0.1
- uses: actions/download-artifact@v8.0.1
with:
name: dist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.13.0
- uses: pypa/gh-action-pypi-publish@v1.13.0
release:
name: GitHub Release
needs: [version-check, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- uses: actions/download-artifact@v8.0.1
with:
name: dist
path: dist
- uses: softprops/action-gh-release@v2.6.1
with:
tag_name: v${{ needs.version-check.outputs.version }}
name: v${{ needs.version-check.outputs.version }}
files: dist/*
generate_release_notes: true
make_latest: true
-34
View File
@@ -1,34 +0,0 @@
name: Tests
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v7.5.0
- name: Install dependencies
run: uv pip install --system ".[dev]"
- name: Write cookies.json
if: ${{ env.COOKIES_JSON != '' }}
run: echo "$COOKIES_JSON" > cookies.json
env:
COOKIES_JSON: ${{ secrets.COOKIES_JSON }}
- name: Run tests
run: pytest