fix release workflows #76
This file contains hidden or 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 Conda | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - '.github/workflows/**' | |
| jobs: | |
| conda-publish: | |
| name: Build and maybe publish Conda package | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout repository and fetch tags | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| python-version: '3.12' | |
| channels: conda-forge | |
| auto-update-conda: true | |
| activate-environment: false | |
| - name: Create Conda environment with all dependencies | |
| shell: bash | |
| run: | | |
| 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 }} | |
| 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 | |
| # 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 -n dl1dh anaconda upload \ | |
| "$PACKAGE_PATH" \ | |
| --force \ | |
| --user "$ANACONDA_CHANNEL" | |
| else | |
| echo "Skipping upload (event: ${{ github.event_name }})" | |
| fi |