fix: workflow #5
Workflow file for this run
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 and Publish Python Node Package | |
on: | |
push: | |
tags: | |
- '*' | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
macos: | |
runs-on: macos-latest | |
permissions: | |
id-token: write | |
contents: read | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
target: [x86_64, aarch64] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Create Python module structure | |
run: | | |
mkdir -p sn_node/python/safenode | |
cat > sn_node/python/safenode/__init__.py << EOL | |
from ._safenode import * | |
__version__ = "${{ github.ref_name }}" | |
EOL | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist | |
sccache: 'true' | |
working-directory: ./sn_node | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.python-version }}-${{ matrix.target }} | |
path: sn_node/dist/*.whl | |
if-no-files-found: error | |
retention-days: 1 | |
compression-level: 9 | |
continue-on-error: true | |
timeout-minutes: 10 | |
env: | |
ACTIONS_STEP_DEBUG: true | |
ACTIONS_RUNNER_DEBUG: true | |
windows: | |
runs-on: windows-latest | |
permissions: | |
id-token: write | |
contents: read | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
target: [x64] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.target }} | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Create Python module structure | |
shell: cmd | |
run: | | |
if not exist "sn_node\python\safenode" mkdir sn_node\python\safenode | |
echo from ._safenode import * > sn_node\python\safenode\__init__.py | |
echo __version__ = "${{ github.ref_name }}" >> sn_node\python\safenode\__init__.py | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
args: --release --out dist | |
sccache: 'true' | |
working-directory: ./sn_node | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.python-version }}-${{ matrix.target }} | |
path: sn_node/dist/*.whl | |
if-no-files-found: error | |
retention-days: 1 | |
compression-level: 9 | |
continue-on-error: true | |
timeout-minutes: 10 | |
env: | |
ACTIONS_STEP_DEBUG: true | |
ACTIONS_RUNNER_DEBUG: true | |
linux: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
target: [x86_64] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
target: x86_64-unknown-linux-gnu | |
- name: Install dependencies | |
run: | | |
python -m pip install --user cffi | |
python -m pip install --user patchelf | |
rustup component add rustfmt | |
- name: Create Python module structure | |
run: | | |
mkdir -p sn_node/python/safenode | |
cat > sn_node/python/safenode/__init__.py << EOL | |
from ._safenode import * | |
__version__ = "${{ github.ref_name }}" | |
EOL | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: --release --out dist | |
sccache: 'true' | |
working-directory: ./sn_node | |
before-script-linux: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup component add rustfmt | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.python-version }}-${{ matrix.target }} | |
path: sn_node/dist/*.whl | |
if-no-files-found: error | |
retention-days: 1 | |
compression-level: 9 | |
continue-on-error: true | |
timeout-minutes: 10 | |
env: | |
ACTIONS_STEP_DEBUG: true | |
ACTIONS_RUNNER_DEBUG: true | |
sdist: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Create Python module structure | |
run: | | |
mkdir -p sn_node/python/safenode | |
cat > sn_node/python/safenode/__init__.py << EOL | |
from ._safenode import * | |
__version__ = "${{ github.ref_name }}" | |
EOL | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
working-directory: ./sn_node | |
- name: Upload sdist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sdist | |
path: sn_node/dist/*.tar.gz | |
if-no-files-found: error | |
retention-days: 1 | |
compression-level: 9 | |
continue-on-error: true | |
timeout-minutes: 10 | |
env: | |
ACTIONS_STEP_DEBUG: true | |
ACTIONS_RUNNER_DEBUG: true | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [macos, windows, linux, sdist] | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Create dist directory | |
run: mkdir -p dist | |
# Download all artifacts at once | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- name: Prepare dist directory | |
run: | | |
find dist -type f -name "*.whl" -exec mv {} dist/ \; | |
find dist -type f -name "*.tar.gz" -exec mv {} dist/ \; | |
rm -rf dist/*/ | |
echo "Final dist directory contents:" | |
ls -la dist/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: dist/ | |
verbose: true | |
print-hash: true |