From 42188af02b9073598af284fe6aeac095c354fec1 Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Tue, 18 Jul 2023 08:11:36 +0800 Subject: [PATCH] CI: release to PyPI (#500) --- .github/workflows/crates-publish.yml | 2 +- .github/workflows/update_pypi.yml | 99 ++++++++++++++++++++++++++++ README.md | 1 + pyproject.toml | 16 +++++ 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update_pypi.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/crates-publish.yml b/.github/workflows/crates-publish.yml index 4d8c8056..5b291239 100644 --- a/.github/workflows/crates-publish.yml +++ b/.github/workflows/crates-publish.yml @@ -4,7 +4,7 @@ on: # types: # - completed release: - types: [published, edited] + types: [published] name: Publish to crates.io on release diff --git a/.github/workflows/update_pypi.yml b/.github/workflows/update_pypi.yml new file mode 100644 index 00000000..489ca2a9 --- /dev/null +++ b/.github/workflows/update_pypi.yml @@ -0,0 +1,99 @@ +name: Update PyPi + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + linux: + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64, x86, aarch64] + steps: + - uses: actions/checkout@v3 + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + windows: + runs-on: windows-latest + strategy: + matrix: + target: [x64, x86] + steps: + - uses: actions/checkout@v3 + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + macos: + runs-on: macos-latest + strategy: + matrix: + target: [x86_64, aarch64] + steps: + - uses: actions/checkout@v3 + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + release: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [linux, windows, macos, sdist] + steps: + - uses: actions/download-artifact@v3 + with: + name: wheels + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --skip-existing * diff --git a/README.md b/README.md index 1298902e..cede29ec 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ To remedy this, **Topgrade** detects which tools you use and runs the appropriat - Void Linux: [XBPS](https://voidlinux.org/packages/?arch=x86_64&q=topgrade) - macOS: [Homebrew](https://formulae.brew.sh/formula/topgrade) or [MacPorts](https://ports.macports.org/port/topgrade/) - Windows: [Scoop](https://github.com/ScoopInstaller/Main/blob/master/bucket/topgrade.json) +- PyPi: [pip](https://pypi.org/project/topgrade/) Other systems users can either use `cargo install` or the compiled binaries from the release page. The compiled binaries contain a self-upgrading feature. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..677c78f9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +requires = ["maturin>=1.0,<2.0"] +build-backend = "maturin" + +[project] +name = "topgrade" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] + + +[tool.maturin] +bindings = "bin"