From ef075e70b1c4042874437f715bdf912bb215f7a6 Mon Sep 17 00:00:00 2001 From: ed cuss Date: Fri, 11 Jul 2025 23:54:45 +0100 Subject: [PATCH 1/3] chore: format ci and publish --- .github/workflows/ci.yaml | 17 ++-- .github/workflows/publish.yaml | 141 ++++++++++++++++----------------- 2 files changed, 76 insertions(+), 82 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 23a5722..74c5029 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,14 +1,11 @@ name: Rust - -on: - push: - branches: [ "main" ] +'on': pull_request: - branches: [ "main" ] - + branches: + - main + - dev env: CARGO_TERM_COLOR: always - jobs: build: runs-on: ubuntu-latest @@ -18,8 +15,7 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose - - lint: + lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -27,8 +23,7 @@ jobs: run: rustup component add clippy - name: clippy check run: cargo clippy - - formatting: + formatting: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 88f5285..eea446b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,76 +1,75 @@ name: Build & maybe upload PyPI package 'on': - push: - branches: - - main - tags: - - '*' - pull_request: - branches: - - main - release: - types: - - published - workflow_dispatch: + push: + branches: + - main + tags: + - '*' + pull_request: + branches: + - main + release: + types: + - published + workflow_dispatch: null permissions: - contents: read - id-token: write + contents: read + id-token: write jobs: - build-package: - name: Build & verify package - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - - macos-latest - steps: - - name: checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build wheels with maturin - uses: PyO3/maturin-action@v1 - with: - command: build - args: --release --out dist --sdist --verbose - - name: Upload built packages - uses: actions/upload-artifact@v4 - with: - name: Packages-${{ matrix.os }} - path: dist + build-package: + name: Build & verify package + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + steps: + - name: checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Build wheels with maturin + uses: PyO3/maturin-action@v1 + with: + command: build + args: --release --out dist --sdist --verbose + - name: Upload built packages + uses: actions/upload-artifact@v4 + with: + name: Packages-${{ matrix.os }} + path: dist + release-test-pypi: + name: Publish in-dev package to test.pypi.org + environment: release-test-pypi + if: github.repository_owner == 'second-ed' && github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: build-package + steps: + - name: Download packages built by build-and-inspect-python-package + uses: actions/download-artifact@v4 + with: + pattern: Packages-* + path: dist + merge-multiple: true + - name: Upload package to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + release-pypi: + name: Publish released package to pypi.org + environment: release-pypi + if: github.repository_owner == 'second-ed' && github.event.action == 'published' + runs-on: ubuntu-latest + needs: build-package + steps: + - name: Download packages built by build-and-inspect-python-package + uses: actions/download-artifact@v4 + with: + pattern: Packages-* + path: dist + merge-multiple: true + - name: Upload package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 - release-test-pypi: - name: Publish in-dev package to test.pypi.org - environment: release-test-pypi - if: github.repository_owner == 'second-ed' && github.event_name == 'push' && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - needs: build-package - steps: - - name: Download packages built by build-and-inspect-python-package - uses: actions/download-artifact@v4 - with: - pattern: Packages-* - path: dist - merge-multiple: true - - name: Upload package to Test PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - - release-pypi: - name: Publish released package to pypi.org - environment: release-pypi - if: github.repository_owner == 'second-ed' && github.event.action == 'published' - runs-on: ubuntu-latest - needs: build-package - steps: - - name: Download packages built by build-and-inspect-python-package - uses: actions/download-artifact@v4 - with: - pattern: Packages-* - path: dist - merge-multiple: true - - name: Upload package to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From 8257944b32f5a5f17bfd4f61500cb52ee60e0962 Mon Sep 17 00:00:00 2001 From: ed cuss Date: Thu, 17 Jul 2025 20:35:31 +0100 Subject: [PATCH 2/3] ci: update build matrix --- .github/workflows/publish.yaml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index eea446b..dd41fbe 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -23,22 +23,31 @@ jobs: matrix: os: - ubuntu-latest - - windows-latest - macos-latest + - windows-latest + python-version: + - '3.10' + - '3.11' + - '3.12' + - '3.13' steps: - name: checkout repo uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} - name: Build wheels with maturin uses: PyO3/maturin-action@v1 with: command: build - args: --release --out dist --sdist --verbose + args: --release --out dist --sdist --verbose --interpreter python${{ matrix.python-version }} - name: Upload built packages uses: actions/upload-artifact@v4 with: - name: Packages-${{ matrix.os }} + name: wheel-${{ matrix.os }}-py${{ matrix.python-version }} path: dist release-test-pypi: name: Publish in-dev package to test.pypi.org @@ -50,7 +59,7 @@ jobs: - name: Download packages built by build-and-inspect-python-package uses: actions/download-artifact@v4 with: - pattern: Packages-* + pattern: wheel-* path: dist merge-multiple: true - name: Upload package to Test PyPI @@ -67,9 +76,8 @@ jobs: - name: Download packages built by build-and-inspect-python-package uses: actions/download-artifact@v4 with: - pattern: Packages-* + pattern: wheel-* path: dist merge-multiple: true - name: Upload package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - From 20104be5f19c93e35c50b84b252da4be7d884efa Mon Sep 17 00:00:00 2001 From: ed cuss Date: Thu, 17 Jul 2025 20:42:25 +0100 Subject: [PATCH 3/3] docs: update version and README.md --- Cargo.toml | 2 +- README.md | 28 ++++++++++++++++++++++++++-- pyproject.toml | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 111dc1f..be3eaeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "readme-update" -version = "0.1.1" +version = "0.1.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 5e5c50a..45b2cd2 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,29 @@ It will update in place if the `# Scripts` block exists or else it will append i | `example_usage.py` | | | :: -# Some line afterwards -blah blah +# To install the package +```shell +pip install readme-update +``` + +# Usage +Assuming its is run from this location. +```shell +root/ + scripts/ + example_script.py + README.md +``` + +# example_script.py +```python +import readme_update +from pathlib import Path + +path = Path(__file__) + +readme_update.py_main( + str(path.parent), + str(path.parents[1] / "README.md") +) +``` diff --git a/pyproject.toml b/pyproject.toml index a182956..ae5fa07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "readme-update" -version = "0.1.1" +version = "0.1.2" readme = "README.md" requires-python = ">=3.10" classifiers = [