Skip to content

Commit

Permalink
refactor(project): build with rust
Browse files Browse the repository at this point in the history
  • Loading branch information
HsiangNianian committed Mar 2, 2024
1 parent efe8d87 commit df1bf4d
Show file tree
Hide file tree
Showing 14 changed files with 1,182 additions and 946 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release-Packages

on:
push:
tags:
- "v*"
# release:
# types: [published]
workflow_dispatch:

jobs:
build-packages:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3

- uses: pdm-project/setup-pdm@v4
name: Setup PDM
with:
python-version: 3.9
cache: true

- name: Install dependencies
run: pdm install

# - run: pdm publish
# shell: bash

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-apscheduler

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-kook

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-cqhttp

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-dingtalk

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-bililive

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-console

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-red

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-gensokyo


151 changes: 103 additions & 48 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,119 @@
# This file is autogenerated by maturin v1.4.0
# To update, run
#
# maturin generate-ci github
#
name: Release

on:
push:
branches:
- master
tags:
- "v*"
# release:
# types: [published]
- 'v*'
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
linux:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3

- uses: pdm-project/setup-pdm@v4
name: Setup PDM
- uses: actions/setup-python@v4
with:
python-version: 3.9
cache: true

- name: Install dependencies
run: pdm install

- run: pdm publish
shell: bash

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-apscheduler

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-kook

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-cqhttp

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-dingtalk

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-bililive

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-console
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-red
windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

- run: pdm publish
shell: bash
working-directory: ./packages/iamai-adapter-gensokyo
macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
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_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
13 changes: 13 additions & 0 deletions .template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
authors = ["{{authors}}"]
name = "{{project-name}}"
version = "0.1.0"
edition = "2021"

[lib]
name = "hydrorolldemo"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "{{PYO3_VERSION}}", features = ["extension-module"] }
rayon = "1.0.2"
4 changes: 4 additions & 0 deletions .template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable::set("PYO3_VERSION", "0.20.3");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/pyproject.toml", "pyproject.toml");
file::delete(".template");
13 changes: 13 additions & 0 deletions .template/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[build-system]
requires = ["maturin>=1,<2"]
build-backend = "maturin"

[project]
name = "{{project-name}}"
version = "0.1.0"

[project.optional-dependencies]
dev = ["pytest"]

[tool.pytest.ini_options]
addopts = "--benchmark-disable"
Loading

0 comments on commit df1bf4d

Please sign in to comment.