Reorganized files tree, build python and javascript libs from Rust, add #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: push | |
jobs: | |
rust-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test | |
run: cargo test | |
javascript: | |
runs-on: ubuntu-latest | |
needs: rust-test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build | |
id: build | |
working-directory: javascript | |
run: | | |
cp ../README.md ./ | |
npm ci | |
npm run build | |
npm pack | |
- name: Install test dependencies | |
working-directory: javascript/tests | |
run: npm ci && npx playwright install --with-deps | |
- name: Run tests | |
working-directory: javascript | |
run: make test | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: javascript | |
path: javascript/evmole-*.tgz | |
python-wheel: | |
needs: rust-test | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
platform: | |
- runner: ubuntu-latest | |
os: linux | |
target: x86_64 | |
- runner: windows-latest | |
os: windows | |
target: x64 | |
- runner: macos-latest | |
os: macos | |
target: universal2-apple-darwin | |
runs-on: ${{ matrix.platform.runner }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build | |
uses: PyO3/maturin-action@v1 | |
with: | |
maturin-version: 1.7.0 | |
target: ${{ matrix.platform.target }} | |
manylinux: auto | |
args: -i ${{ matrix.python-version }} --release --out dist | |
- name: Install wheel | |
run: pip3 install ${{ matrix.platform.os == 'windows' && '(get-item .\dist\*.whl)' || 'dist/*.whl' }} | |
- name: Test | |
run: python3 python/test_python.py | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-${{ matrix.platform.os}}-${{ matrix.python-version }} | |
path: dist/*.whl | |
compression-level: 0 | |
python-sdist: | |
runs-on: ubuntu-latest | |
needs: rust-test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
maturin-version: 1.7.0 | |
command: sdist | |
args: --out dist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-sdist | |
path: dist | |
compression-level: 0 | |
python-sdist-test: | |
# ubuntu-latest image (https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md) have Rust installed | |
runs-on: ubuntu-latest | |
needs: python-sdist | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.13 | |
allow-prereleases: true | |
- uses: actions/download-artifact@v4 | |
with: | |
name: python-sdist | |
- name: Build and install wheel | |
run: pip3 install *.tar.gz | |
- name: Test | |
run: python3 python/test_python.py | |
release: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') # only on tagged releases | |
needs: [javascript, python-wheel, python-sdist, python-sdist-test] | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # need tags to generate release notes | |
- name: Release Notes | |
run: | | |
echo '## Changes since previous release:' > changelog.md | |
git log --oneline $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:"- [%h](https://github.com/cdump/evmole/commit/%H) %s" >> changelog.md | |
cat changelog.md | |
- name: Download Python Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: python-* | |
path: dist-py | |
merge-multiple: true | |
- name: Download Javascript Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: javascript | |
path: ./javascript/ | |
- name: Github Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
body_path: changelog.md | |
files: | | |
javascript/evmole-*.tgz | |
dist-py/* | |
- name: Publish rust | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }} | |
run: cargo publish --allow-dirty --dry-run | |
- name: Publish javascript | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
working-directory: javascript | |
run: npm publish --provenance --dry-run *.tgz | |
- name: Publish python | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
pip install twine | |
twine upload -r testpypi ./dist-py/* || true |