Skip to content
Merged
7 changes: 4 additions & 3 deletions .github/conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ build:

requirements:
host:
- python >=3.10
- python >=3.12
- pip
- setuptools >=65
- setuptools_scm >=6.2
run:
- python >=3.10
- python >=3.12
- astropy
- numpy
- pandas
Expand All @@ -30,7 +30,8 @@ requirements:
- traitlets
- pydot
- setuptools
- ctapipe>=0.23,<0.26
- ctapipe>=0.28
- eventio


test:
Expand Down
38 changes: 22 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Release CD
name: Release PyPI CD

on:
release:
types: [published]
pull_request:
paths:
- '.github/workflows/**'
workflow_dispatch:

jobs:
pypi-publish:
Expand All @@ -20,28 +24,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
pyv: ['3.10']
pyv: ['3.12']
max-parallel: 5
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.pyv }}
run: |
conda install -y python=${{ matrix.pyv }}

- name: Add conda to system path
run: |
#$CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH

- name: Install dependencies

- name: Set up Miniconda and install dependencies
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.pyv }}
activate-environment: dl1dh
channels: conda-forge
packages: ctapipe

- name: Upgrade pip and build tools
run: |
conda env update --file environment.yml --name base
pip install --upgrade pip build

- name: Build package
run: |
python --version
pip install -U build
python -m build

- name: Publish package distributions to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
54 changes: 30 additions & 24 deletions .github/workflows/release_conda.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@
name: Release Conda
name: Release Conda CD

on:
release:
types: [published]
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/**'

jobs:
publish:
conda-publish:
name: Publish release to Conda
runs-on: ubuntu-22.04

steps:
- name: Checkout repository and fetch tags
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Miniconda and Conda Tools
fetch-depth: 0

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.10'
channels: conda-forge
python-version: '3.12'
channels: conda-forge
auto-update-conda: true
mamba-version: "*"
activate-environment: false

- name: Install anaconda-client and conda-build
activate-environment: false

- name: Create Conda environment with all dependencies
shell: bash
run: |
mamba install anaconda-client conda-build -y

- name: Conda Build and Upload Package
conda create -y -n dl1dh -c conda-forge python=3.12 ctapipe conda-build anaconda-client
python --version

- name: Conda Build (and maybe Upload)
shell: bash
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
CONDA_RECIPE_DIR=".github/conda"
ANACONDA_CHANNEL="ctlearn-project"

# Get latest tag or default to dev
FULL_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0+dev")
VERSION="${FULL_TAG#v}"
VERSION="${VERSION#V}"

echo "Building package version: $VERSION"
export PACKAGE_VERSION=$VERSION

conda run conda build $CONDA_RECIPE_DIR

PACKAGE_PATH=$(conda run conda build $CONDA_RECIPE_DIR --output)

if [[ "$VERSION" != "0.0.0+dev" ]]; then

# Build the package
PACKAGE_PATH=$(conda run -n dl1dh conda build "$CONDA_RECIPE_DIR" --output)
conda run -n dl1dh conda build "$CONDA_RECIPE_DIR"

# Upload only if this is a release
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "Uploading $PACKAGE_PATH to $ANACONDA_CHANNEL channel..."
conda run anaconda upload \
conda run -n dl1dh anaconda upload \
"$PACKAGE_PATH" \
--force \
--user $ANACONDA_CHANNEL
--user "$ANACONDA_CHANNEL"
else
echo "Skipping upload: Version is $VERSION (development)."
echo "Skipping upload (event: ${{ github.event_name }})"
fi
Loading