[rewrite] Rust all the things #36
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: Rust-py | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "*" | |
pull_request: | |
branches: | |
- "*" | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
linux: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git fetch --prune --unshallow | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install maturin | |
run: | | |
python3 -m pip install maturin twine | |
# Gather the name of the latest tag on the current main branch | |
- name: Get the latest tag | |
id: get_tag | |
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT | |
- name: Build the package | |
run: | | |
maturin build -i python3.11 --release --out dist --target "x86_64-unknown-linux-gnu" | |
mv dist/datago-0.0.0-cp311-cp311-linux_x86_64.whl dist/datago-${{ steps.get_tag.outputs.tag }}-cp311-cp311-linux_x86_64.whl | |
- name: Test package | |
env: | |
DATAROOM_API_KEY: ${{ secrets.DATAROOM_API_KEY }} | |
DATAROOM_TEST_SOURCE: ${{ secrets.DATAROOM_TEST_SOURCE }} | |
DATAROOM_API_URL: ${{ secrets.DATAROOM_API_URL }} | |
# needs to be replaced with the live version of the package / evolving version number | |
run: | | |
python3 -m pip install dist/datago-${{ steps.get_tag.outputs.tag }}-cp311-cp311-linux_x86_64.whl | |
python3 -m pip install -r requirements-tests.txt | |
cd python | |
python3 -m pytest -v . | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.platform.target }} | |
path: dist | |
sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
- name: Upload sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: dist | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} | |
needs: [linux, sdist] | |
permissions: | |
# Use to sign the release artifacts | |
id-token: write | |
# Used to upload release artifacts | |
contents: write | |
# Used to generate artifact attestation | |
attestations: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: "wheels-*/*" | |
- name: Publish to PyPI | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
uses: PyO3/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
with: | |
command: upload | |
args: --non-interactive --skip-existing wheels-*/* |