Skip to content

Another attempt

Another attempt #14

Workflow file for this run

name: Conda Build & Publish
on:
workflow_dispatch:
pull_request:
push:
branches: [master, develop]
tags:
- "v**"
release:
types: [published]
jobs:
# ---------------------------------------------------------------------------
# Version sanity checks
# ---------------------------------------------------------------------------
check-version-strings:
runs-on: ubuntu-latest
container: python:3.12-slim
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: pip install pyyaml
- name: Test version strings
run: python testversion.py
# ---------------------------------------------------------------------------
# Conda build (Windows only, matrix Python versions)
# ---------------------------------------------------------------------------
build-conda-windows:
needs: check-version-strings
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
# ---------------------- IMPORTANT FIX ----------------------
# Never use defaults. Only conda-forge ensures OpenBLAS stack.
- name: Set up Miniconda (conda-forge only)
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
activate-environment: build
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: strict
use-mamba: true
# Guarantee no MKL cache in runner
- name: Configure clean package cache
shell: bash
run: |
mkdir -p ${GITHUB_WORKSPACE}/conda-pkgs
echo "CONDA_PKGS_DIRS=${GITHUB_WORKSPACE}/conda-pkgs" >> $GITHUB_ENV
# ---------------------- Required for Cython ----------------------
- name: Set up MSVC toolchain
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
# ---------------------- Conda build ----------------------
- name: Build conda package
shell: bash -l {0}
run: |
echo "Channels:"
conda config --show channels
echo "Building package for Python ${{ matrix.python-version }}"
mkdir -p build_artifacts
conda build . \
--no-include-recipe \
--output-folder build_artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: conda-windows-py${{ matrix.python-version }}
path: build_artifacts/**/*
if-no-files-found: error
# ---------------------------------------------------------------------------
# Publish (runs only on tagged releases)
# ---------------------------------------------------------------------------
publish-conda:
needs: build-conda-windows
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: anaconda
url: https://anaconda.org/ifilot/pyqint
steps:
- uses: actions/checkout@v4
# Publishing environment ALSO must be conda-forge-only
- name: Set up Miniconda (conda-forge only)
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
activate-environment: upload
channels: conda-forge
channel-priority: strict
use-mamba: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: packages
- name: Publish to Anaconda
shell: bash -l {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
echo "Packages ready for upload:"
ls -R packages
anaconda upload packages/**/*.tar.bz2 --force