Ensure only one version of pyo3-stub-gen-derive is used in the project #136
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
# | |
# This action will: | |
# Build python wheels | |
# Build libraries | |
# Publish a release in GitHub | |
# Publish to pypi | |
# Publish to crates.io | |
# | |
# This file contains parts autogenerated by maturin v1.7.2 | |
# | |
# maturin generate-ci github --platform manylinux macos | |
# | |
name: Releasev2 | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
jobs: | |
build_linux: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
# - runner: ubuntu-latest | |
# target: aarch64 | |
# - runner: ubuntu-latest | |
# target: armv7 | |
# - runner: ubuntu-latest | |
# target: ppc64le | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build linux wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --all-features --out dist -i 3.9 3.10 3.11 3.12 3.13 | |
manylinux: auto | |
- name: Upload linux wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.platform.target }} | |
path: dist | |
- name: Build linux C and Rust libraries | |
run: | | |
# Fix permissions- output files from maturn-action end up owned by root | |
# so lets change them back to root:root | |
sudo chown -R runner:docker . | |
export TAG="$(git describe --tags)" | |
echo "TAG=$TAG" | |
# determine which target cpus for rustc to build for from machine type | |
export ARCH="$(uname -m)" | |
case $ARCH in | |
x86_64) | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
export TARGETS="x86-64 x86-64-v2 x86-64-v3" | |
else | |
export TARGETS="x86-64" | |
fi | |
;; | |
*) echo "unknown arch (uname -m) $ARCH"; exit 1 ;; | |
esac | |
# determine which library file extensions to include in archive from kernel | |
export KERNEL="$(uname -s | tr '[:upper:]' '[:lower:]')" | |
case $KERNEL in | |
linux*) export LIB_GLOB="{a,so}" ;; | |
*) echo "unknown kernel (uname -s) $KERNEL"; exit 1 ;; | |
esac | |
for TARGET in $TARGETS; do | |
echo "building kernel-target $KERNEL-$TARGET" | |
export RUSTFLAGS="-C target-cpu=$TARGET" | |
# Build C objects | |
cargo build --release --features cfitsio-static,examples | |
# Create new release asset tarballs | |
# Get some debug | |
ls -la target/release | |
ls -la include | |
ls -la . | |
eval mv target/release/libmwalib.${LIB_GLOB} include/mwalib.h . | |
eval tar -acvf mwalib-${TAG}-${KERNEL}-${TARGET}.tar.gz \ | |
LICENSE LICENSE-cfitsio README.md CHANGELOG.md \ | |
libmwalib.${LIB_GLOB} mwalib.h | |
eval tar -acvf mwalib-${TAG}-${KERNEL}-${TARGET}-python.tar.gz \ | |
LICENSE LICENSE-cfitsio README.md CHANGELOG.md \ | |
./dist/*.whl | |
done | |
- name: Upload linux tarball | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-${{ matrix.platform.target }}.tar.gz | |
path: "*.tar.gz" | |
if-no-files-found: error | |
build_macos: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: # see https://github.com/actions/runner-images?tab=readme-ov-file#available-images for runner types | |
- runner: macos-13 | |
target: x86_64 | |
- runner: macos-14 | |
target: aarch64 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install automake and autoconf | |
run: | | |
brew install automake autoconf | |
- name: Build macos wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --all-features --out dist -i 3.9 3.10 3.11 3.12 3.13 | |
- name: Upload macos wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }} | |
path: dist | |
- name: Build C and Rust libraries | |
run: | | |
export TAG="$(git describe --tags)" | |
echo "TAG=$TAG" | |
# determine which target cpus for rustc to build for from machine type | |
export ARCH="$(uname -m)" | |
case $ARCH in | |
x86_64) | |
export TARGET="x86-64";; | |
arm64) export TARGET="arm64";; | |
*) echo "unknown arch (uname -m) $ARCH"; exit 1 ;; | |
esac | |
# determine which library file extensions to include in archive from kernel | |
export KERNEL="$(uname -s | tr '[:upper:]' '[:lower:]')" | |
case $KERNEL in | |
darwin*) export LIB_GLOB="{a,dylib}" ;; | |
linux*) export LIB_GLOB="{a,so}" ;; | |
*) echo "unknown kernel (uname -s) $KERNEL"; exit 1 ;; | |
esac | |
echo "building kernel-target $KERNEL-$TARGET" | |
export RUSTFLAGS="-C target-cpu=$TARGET" | |
# Build C objects | |
cargo build --release --features examples,cfitsio-static | |
# Get some debug | |
ls -la target/release | |
ls -la include | |
ls -la . | |
# Create new release asset tarballs | |
eval mv target/release/libmwalib.${LIB_GLOB} include/mwalib.h . | |
eval tar -acvf mwalib-${TAG}-${KERNEL}-${TARGET}.tar.gz \ | |
LICENSE LICENSE-cfitsio README.md CHANGELOG.md \ | |
libmwalib.${LIB_GLOB} mwalib.h | |
eval tar -acvf mwalib-${TAG}-${KERNEL}-${TARGET}-python.tar.gz \ | |
LICENSE LICENSE-cfitsio README.md CHANGELOG.md \ | |
./dist/*.whl | |
- name: Upload macos tarball | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform.runner }}-${{ matrix.platform.target }}.tar.gz | |
path: "*.tar.gz" | |
if-no-files-found: error | |
create-github-release: | |
name: Create a new github release | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
needs: [build_linux, build_macos] | |
environment: CI | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.ref_name }} | |
shell: bash | |
run: | | |
gh release create "$tag" \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ | |
--generate-notes *.tar.gz | |
pypi_release: | |
name: Publish to pypi | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} | |
environment: CI | |
needs: [create-github-release] | |
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: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
- 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-*/* | |
rust_release: | |
name: Publish to crates.io | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
needs: [create-github-release] | |
environment: CI | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable, minimal toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
# We install cfitsio because when releasing to crates.io, it runs | |
# the rust docs generation which fails if our code does any | |
# writing. With feature cfitsio-static, it has to build cfitsio which | |
# involves writing so have to build without that feature when pushing | |
# to crates.io | |
- name: Install cfitsio 3.49 | |
run: | | |
curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.49.tar.gz" -o cfitsio.tar.gz | |
tar -xf cfitsio.tar.gz | |
rm cfitsio.tar.gz | |
cd cfitsio-3.49 | |
# Enabling SSE2/SSSE3 could cause portability problems, but it's unlikely that anyone | |
# is using such a CPU... | |
# https://stackoverflow.com/questions/52858556/most-recent-processor-without-support-of-ssse3-instructions | |
# Disabling curl just means you cannot fits_open() using a URL. | |
CFLAGS="-O3" ./configure --prefix=/usr/local --enable-reentrant --enable-sse2 --enable-ssse3 --disable-curl | |
make -j | |
sudo make install | |
sudo ldconfig | |
cd .. | |
rm -rf cfitsio-3.49 | |
- name: Build on latest stable rust | |
run: cargo build --release --features examples | |
- name: Run tests on latest stable rust | |
run: cargo test --release --features examples | |
- uses: katyo/publish-crates@v2 | |
with: | |
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
args: --no-verify |