diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 850821aa..8b74b3d5 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -29,9 +29,47 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 + conda-build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + mamba-version: "*" + environment-file: environment.yml + - name: Build python wheel + run: | + python -m build --wheel --no-isolation + check-wheel-contents dist/shiver-*.whl + - name: Build conda library + shell: bash -l {0} + run: | + # set up environment + cd conda.recipe + echo "versioningit $(versioningit ../)" + # build the package + VERSION=$(versioningit ../) conda mambabuild --output-folder . . + conda verify noarch/shiver*.tar.bz2 + - name: Deploy to Anaconda + shell: bash -l {0} + if: startsWith(github.ref, 'refs/tags/v') + env: + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} + IS_RC: ${{ contains(github.ref, 'rc') }} + run: | + # label is main or rc depending on the tag-name + CONDA_LABEL="main" + if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi + echo pushing ${{ github.ref }} with label $CONDA_LABEL + anaconda upload --label $CONDA_LABEL conda.recipe/noarch/shiver*.tar.bz2 + trigger-deploy: runs-on: ubuntu-22.04 - needs: [tests] + needs: [tests, conda-build] # only trigger deploys from protected branches and tags if: ${{ github.ref_protected || github.ref_type == 'tag' }} steps: diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml new file mode 100644 index 00000000..1a53e8a2 --- /dev/null +++ b/conda.recipe/meta.yaml @@ -0,0 +1,42 @@ +# load information from setup.cfg/setup.py +{% set data = load_setup_py_data() %} +{% set license = data.get('license') %} +{% set description = data.get('description') %} +{% set url = data.get('url') %} +# this will get the version set by environment variable +{% set version = environ.get('VERSION') %} +{% set version_number = environ.get('GIT_DESCRIBE_NUMBER', '0') | string %} + + +package: + name: shiver + version: {{ version_number }} + +source: + path: .. + +build: + noarch: python + linux-64: python + number: {{ version_number }} + string: py{{py}} + script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv + +requirements: + host: + - python + - versioningit + + build: + - setuptools + - versioningit + + run: + - mantidworkbench + +about: + home: {{ url }} + license: {{ license }} + license_family: GPL + license_file: ../LICENSE + summary: {{ description }} diff --git a/environment.yml b/environment.yml index feb3a4c1..56d9292f 100644 --- a/environment.yml +++ b/environment.yml @@ -3,6 +3,9 @@ channels: - conda-forge - mantid/label/nightly dependencies: + - boa + - conda-build + - conda-verify - mantidworkbench - pre-commit - versioningit @@ -10,8 +13,11 @@ dependencies: - pytest=7.2.1 - pytest-qt=4.2.0 - pytest-cov=4.0.0 + - setuptools - sphinx + - python-build - pip - pip: - - https://oncat.ornl.gov/packages/pyoncat-1.4.1-py3-none-any.whl + - https://oncat.ornl.gov/packages/pyoncat-1.6.1-py2.py3-none-any.whl - sphinx-rtd-theme + - check-wheel-contents diff --git a/pyproject.toml b/pyproject.toml index a677ca8d..6fd70502 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,13 +5,18 @@ dynamic = ["version"] requires-python = ">=3.8" dependencies = [ "mantidworkbench >= 6.6.20230517", - "pyoncat == 1.4.1" + "pyoncat == 1.6.1" ] +[project.urls] +"Homepage" = "https://github.com/neutrons/Shiver/" + [build-system] requires = [ - "setuptools >= 42", - "versioningit" + "setuptools", + "wheel", + "toml", + "versioningit" ] build-backend = "setuptools.build_meta" @@ -24,6 +29,10 @@ file = "src/shiver/_version.py" [tool.setuptools.packages.find] where = ["src"] +exclude = ["tests*", "DGS_SC_scripts*"] + +[tool.setuptools.package-data] +"*" = ["*.yml","*.yaml","*.ini"] [project.gui-scripts] shiver = "shiver:main" diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..99da8fc6 --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +""" +This file is necessary so conda can read the contents of setup.cfg using +its load_setup_py_data function +""" +from setuptools import setup +from versioningit import get_cmdclasses + +setup(cmdclass=get_cmdclasses())