Bumped version to allow final test of release CI #98
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: Release | |
# Do this on every push with a version tag | |
on: | |
push: | |
tags: | |
- "v*" | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
jobs: | |
build-release: | |
name: Build release for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macOS-latest, macOS-14] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: (macos) install automake and autoconf | |
if: ${{ startsWith(matrix.os, 'macOS') }} | |
run: | | |
brew install automake autoconf | |
- name: Install stable, minimal toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Add Python 3.8 | |
if: ${{ matrix.os != 'macOS-14' }} | |
uses: actions/setup-python@v5 | |
continue-on-error: true | |
with: | |
python-version: "3.8" | |
- name: Add Python 3.9 | |
if: ${{ matrix.os != 'macOS-14' }} | |
uses: actions/setup-python@v5 | |
continue-on-error: true | |
with: | |
python-version: "3.9" | |
- name: Add Python 3.10 | |
uses: actions/setup-python@v5 | |
continue-on-error: true | |
with: | |
python-version: "3.10" | |
- name: Add Python 3.11 | |
uses: actions/setup-python@v5 | |
continue-on-error: true | |
with: | |
python-version: "3.11" | |
- name: Add Python 3.12 | |
uses: actions/setup-python@v5 | |
continue-on-error: true | |
with: | |
python-version: "3.12" | |
- name: install cfitsio | |
env: | |
# TODO: CFITSIO_VERSION: 4.4.0 | |
CFITSIO_VERSION: 3.49 | |
run: | | |
cd /tmp | |
curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz | |
tar -xf cfitsio.tar.gz | |
rm cfitsio.tar.gz | |
cd cfitsio-${CFITSIO_VERSION} | |
./configure --prefix=/usr/local --enable-reentrant --disable-curl | |
sudo make shared | |
sudo make install | |
cd .. | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
sudo ldconfig | |
fi | |
- name: install maturin | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install maturin | |
- name: build mwalib | |
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) | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
export TARGETS="x86-64 x86-64-v2 x86-64-v3" | |
else | |
export TARGETS="x86-64" | |
fi | |
;; | |
arm64) export TARGETS="apple-m1" ;; | |
*) 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 | |
# determine which python versions are available | |
export PYTHONS=$(maturin list-python 2>&1 | grep CPython | cut -d' ' -f 4 | tr $'\n' ' ') | |
for TARGET in $TARGETS; do | |
echo "building target $TARGET" | |
export RUSTFLAGS="-C target-cpu=$TARGET" | |
# Build python first | |
MWALIB_LINK_STATIC_CFITSIO=1 maturin build --release --features python,cfitsio-static --strip -i $PYTHONS | |
# Build C objects | |
MWALIB_LINK_STATIC_CFITSIO=1 cargo build --release --features examples,cfitsio-static | |
# Create new release asset tarballs | |
eval mv target/wheels/*.whl 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 \ | |
./*.whl | |
done | |
- name: Upload tarball | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}.tar.gz | |
path: "*.tar.gz" | |
if-no-files-found: error | |
create-rust-release: | |
name: Publish to crates.io | |
runs-on: ubuntu-latest | |
needs: [build-release] | |
environment: CI | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable, minimal toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: install cfitsio | |
env: | |
# TODO: CFITSIO_VERSION: 4.4.0 | |
CFITSIO_VERSION: 3.49 | |
run: | | |
cd /tmp | |
curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz | |
tar -xf cfitsio.tar.gz | |
rm cfitsio.tar.gz | |
cd cfitsio-${CFITSIO_VERSION} | |
./configure --prefix=/usr/local --enable-reentrant --disable-curl | |
sudo make shared | |
sudo make install | |
cd .. | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
sudo ldconfig | |
fi | |
- name: Run tests on latest stable rust | |
run: cargo build --release --features cfitsio-static,examples | |
- uses: katyo/publish-crates@v2 | |
with: | |
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
args: --no-verify | |
create-github-and-pypi-release: | |
name: Create a new github and pypi release | |
runs-on: ubuntu-latest | |
needs: [create-rust-release] | |
environment: CI | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ubuntu-latest.tar.gz | |
- name: Download MacOS arm64 artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: macOS-14.tar.gz | |
- name: Download MacOS x86_64 artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: macOS-latest.tar.gz | |
- name: Provide new release asset | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
prerelease: false | |
files: | | |
*.tar.gz | |
- name: Place all python wheels into dir for publish to pypi | |
run: | | |
mkdir for_pypi | |
tar xvf *-darwin-apple-m1-python.tar.gz -C for_pypi/ --wildcards "*.whl" | |
tar xvf *-darwin-x86-64-python.tar.gz -C for_pypi/ --wildcards "*.whl" | |
tar xvf *-linux-x86-64-python.tar.gz -C for_pypi/ --wildcards "*.whl" | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: for_pypi/ | |
password: ${{ secrets.PYPI_API_TOKEN }} |