diff --git a/.conda/recipe/meta.yaml b/.conda/recipe/meta.yaml new file mode 100644 index 0000000..a2ede9c --- /dev/null +++ b/.conda/recipe/meta.yaml @@ -0,0 +1,39 @@ +{% set version = environ["PKG_VERSION"] %} + +package: + name: csdl_alpha + version: {{ version }} + +source: + path: ../.. + +build: + number: 0 + noarch: python + script: "{{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vv" + +requirements: + host: + - python >=3.9 + - pip + - setuptools + run: + - python >=3.9 + - numpy + - scipy + - sympy + - rustworkx + - networkx + - h5py + - pydot + - pytest + +about: + home: https://github.com/LSDOlab/CSDL_alpha + license: LGPL-3.0-or-later + license_file: LICENSE + summary: Computational System Design Language. + +extra: + recipe-maintainers: + - LSDOlab diff --git a/.github/workflows/conda-publish.yml b/.github/workflows/conda-publish.yml new file mode 100644 index 0000000..6a07db1 --- /dev/null +++ b/.github/workflows/conda-publish.yml @@ -0,0 +1,59 @@ +name: Publish Conda package + +on: + push: + tags: ["v*"] + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + env: + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }} + ANACONDA_OWNER: LSDOlab + steps: + - uses: actions/checkout@v4 + + - name: Set up Conda build tools + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: conda-build + python-version: "3.12" + channels: conda-forge + channel-priority: strict + auto-update-conda: false + + - name: Install publishing tools + shell: bash -el {0} + run: conda install --yes --channel conda-forge conda-build anaconda-client + + - name: Read normalized package version + id: package + shell: bash + run: | + python - <<'PY' >> "$GITHUB_OUTPUT" + from pathlib import Path + from packaging.version import Version + import re + text = Path("csdl_alpha/__init__.py").read_text() + match = re.search(r"^__version__\s*=\s*['\"]([^'\"]+)", text, re.M) + assert match, "version not found" + print(f"version={Version(match.group(1))}") + PY + + - name: Build Conda package + shell: bash -el {0} + env: + PKG_VERSION: ${{ steps.package.outputs.version }} + run: conda build .conda/recipe --channel conda-forge --output-folder "$RUNNER_TEMP/conda-bld" + + - name: Publish to Anaconda.org + shell: bash -el {0} + run: | + test -n "$ANACONDA_API_TOKEN" || { echo "::error::ANACONDA_API_TOKEN is not configured"; exit 1; } + package_file="$(find "$RUNNER_TEMP/conda-bld/noarch" -maxdepth 1 -type f \( -name '*.conda' -o -name '*.tar.bz2' \) -print -quit)" + test -n "$package_file" || { echo "::error::Conda build did not produce a noarch package"; exit 1; } + anaconda --token "$ANACONDA_API_TOKEN" upload --user "$ANACONDA_OWNER" --label main "$package_file"