Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 112 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,29 @@ jobs:

sed -i '/^\[workspace\.package\]/,/^\[/{s/^version = ".*"/version = "'"$VERSION"'"/}' Cargo.toml
sed -i '/^\[workspace\.dependencies\]/,/^\[/{s/version = "'"$CURRENT_VERSION"'"/version = "'"$VERSION"'"/g}' Cargo.toml
sed -i '/^\[project\]/,/^\[/{s/^version = ".*"/version = "'"$VERSION"'"/}' pyproject.toml
sed -i '/^\[project\]/,/^\[/{s/^version = ".*"/version = "'"$VERSION"'"/}' python/pyasic-rs/pyproject.toml
python3 - <<'PY'
import json
import os
from pathlib import Path

version = os.environ["VERSION"]
package_dir = Path("javascript/asic-js")

package_json = package_dir / "package.json"
package = json.loads(package_json.read_text())
package["version"] = version
package_json.write_text(json.dumps(package, indent=2) + "\n")

package_lock_json = package_dir / "package-lock.json"
if package_lock_json.exists():
package_lock = json.loads(package_lock_json.read_text())
package_lock["version"] = version
root_package = package_lock.get("packages", {}).get("")
if root_package is not None:
root_package["version"] = version
package_lock_json.write_text(json.dumps(package_lock, indent=2) + "\n")
PY

declare -A CARGO_MANIFESTS=()
CARGO_MANIFESTS["./Cargo.toml"]=1
Expand All @@ -81,7 +103,7 @@ jobs:
codeberg.org/msrd0/cargo-doc2readme:nightly \
cargo doc2readme --expand-macros

git add Cargo.toml pyproject.toml README.md
git add Cargo.toml python/pyasic-rs/pyproject.toml README.md javascript/asic-js/package.json javascript/asic-js/package-lock.json

while IFS= read -r -d '' lockfile; do
git add "$lockfile"
Expand Down Expand Up @@ -193,8 +215,9 @@ jobs:
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: python/pyasic-rs
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
args: --release --out ../../dist --find-interpreter
sccache: true
manylinux: ${{ matrix.manylinux }}

Expand All @@ -216,8 +239,9 @@ jobs:
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
working-directory: python/pyasic-rs
command: sdist
args: --out dist
args: --out ../../dist

- name: Upload sdist
uses: actions/upload-artifact@v6
Expand All @@ -240,7 +264,89 @@ jobs:
- name: Publish crates
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo workspaces publish --from-git --yes --allow-dirty
run: cargo workspaces publish --from-git --yes --allow-dirty --exclude asic-js --exclude pyasic-rs

build-js-bindings:
needs: prepare-release
name: Build JS binding (${{ matrix.artifact }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- artifact: linux-x64
os: ubuntu-24.04
- artifact: windows-x64
os: windows-latest
- artifact: macos-arm64
os: macos-14
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.prepare-release.outputs.tag }}

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: javascript/asic-js/package-lock.json

- uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
working-directory: javascript/asic-js
run: npm ci

- name: Build native binding
working-directory: javascript/asic-js
run: npm run build

- name: Upload native binding
uses: actions/upload-artifact@v6
with:
name: js-native-${{ matrix.artifact }}
path: javascript/asic-js/*.node
if-no-files-found: error

publish-js:
needs:
- prepare-release
- build-js-bindings
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.prepare-release.outputs.tag }}

- uses: actions/setup-node@v6
with:
node-version: "22"
registry-url: https://registry.npmjs.org
cache: npm
cache-dependency-path: javascript/asic-js/package-lock.json

- name: Install dependencies
working-directory: javascript/asic-js
run: npm ci

- uses: actions/download-artifact@v4
with:
pattern: js-native-*
path: javascript/asic-js
merge-multiple: true

- name: Verify package contents
working-directory: javascript/asic-js
run: npm pack --dry-run

- name: Publish to npm
working-directory: javascript/asic-js
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --provenance

release:
runs-on: ubuntu-24.04
Expand All @@ -249,6 +355,7 @@ jobs:
- build-python-wheels
- build-python-sdist
- publish-rust
- publish-js
permissions:
contents: write
id-token: write
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: cargo test --all --locked --exclude asic-rs-pydantic --exclude asic-rs-pydantic-macros
run: cargo test --all --locked --exclude asic-rs-pydantic --exclude asic-rs-pydantic-macros --exclude asic-js --exclude pyasic-rs

python-test:
name: Python Test
Expand All @@ -43,7 +43,8 @@ jobs:
run: .venv/bin/python -m pip install --upgrade pip maturin

- name: Build and install package with test dependencies
run: VIRTUAL_ENV="$PWD/.venv" .venv/bin/maturin develop --features python --extras test
working-directory: python/pyasic-rs
run: VIRTUAL_ENV="$GITHUB_WORKSPACE/.venv" "$GITHUB_WORKSPACE/.venv/bin/maturin" develop --features python --extras test

- name: Run Python tests
run: .venv/bin/python -m pytest python/tests
run: .venv/bin/python -m pytest python/pyasic-rs/tests
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/target
/site
/javascript/asic-js/node_modules
/javascript/asic-js/index.js
/javascript/asic-js/index.d.ts
/javascript/asic-js/*.node
/python/**/__pycache__
/python/pyasic-rs/pyasic_rs/*.pyd
/python/pyasic-rs/pyasic_rs/*.pdb
/python/pyasic-rs/pyasic_rs/*.so
/.idea
/.vscode
/.git
Expand Down
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repos:
- id: check-added-large-files
- id: pretty-format-json
args: ["--autofix", "--indent=2"]
exclude: (^|/)package(-lock)?\.json$
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.0.0
hooks:
Expand All @@ -36,14 +37,14 @@ repos:
- id: uv-lock
alias: generate-pyo3-stubs
name: generate PyO3 stubs
entry: uvx maturin generate-stubs --features python -o python/pyasic_rs
entry: uvx maturin generate-stubs --manifest-path python/pyasic-rs/Cargo.toml --features python -o python/pyasic-rs/pyasic_rs
always_run: true
pass_filenames: false
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.20.0
hooks:
- id: mypy
args: ["--config-file=pyproject.toml"]
args: ["--config-file=python/pyasic-rs/pyproject.toml"]
additional_dependencies: [pydantic==2.12.5]
pass_filenames: false
- repo: local
Expand Down
Loading