Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/conda-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Conda CI

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build-conda:
name: Build conda package (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
use-mamba: true

- name: Install conda build tools
shell: bash -el {0}
run: |
conda install -y -n base conda-build anaconda-client

- name: Resolve release tag
id: resolve_tag
shell: bash
run: |
set -euo pipefail
git fetch --tags --force
TAG="$(git tag --sort=-creatordate | head -n 1 || true)"
if [ -z "$TAG" ]; then
REMOTE_REPO="${{ github.event.repository.full_name }}"
if [ -n "${{ github.event.repository.parent.full_name }}" ]; then
REMOTE_REPO="${{ github.event.repository.parent.full_name }}"
fi
TAG="$(git ls-remote --tags --refs --sort='v:refname' "https://github.com/$REMOTE_REPO.git" \
refs/tags/* | awk '{print $2}' | sed 's#refs/tags/##' | head -n 1)"
fi
if [ -z "$TAG" ]; then
TAG="1.4.5"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"

- name: Build conda package
env:
GIT_DESCRIBE_TAG: ${{ steps.resolve_tag.outputs.tag }}
shell: bash -el {0}
run: |
conda build conda/recipe --no-test

- name: Test built package
env:
GIT_DESCRIBE_TAG: ${{ steps.resolve_tag.outputs.tag }}
shell: bash -el {0}
run: |
PKG_FILE="$(conda build --output conda/recipe)"
conda build --test "$PKG_FILE" -c local
76 changes: 76 additions & 0 deletions .github/workflows/conda-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Conda Release

on:
release:
types: [published]

jobs:
release-conda:
name: Build and upload conda package (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
use-mamba: true

- name: Install conda build tools
shell: bash -el {0}
run: |
conda install -y -n base conda-build anaconda-client

- name: Resolve release tag
id: resolve_tag
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
shell: bash
run: |
set -euo pipefail
TAG="$RELEASE_TAG"
if [ -z "$TAG" ]; then
echo "No tag on release event."
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"

- name: Build conda package
env:
GIT_DESCRIBE_TAG: ${{ steps.resolve_tag.outputs.tag }}
shell: bash -el {0}
run: |
conda build conda/recipe --no-test

- name: Test built package
env:
GIT_DESCRIBE_TAG: ${{ steps.resolve_tag.outputs.tag }}
shell: bash -el {0}
run: |
PKG_FILE="$(conda build --output conda/recipe)"
conda build --test "$PKG_FILE" -c local

- name: Upload package to Anaconda
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
ANACONDA_ORG: ${{ secrets.ANACONDA_ORG }}
GIT_DESCRIBE_TAG: ${{ steps.resolve_tag.outputs.tag }}
shell: bash -el {0}
run: |
set -euo pipefail
PKG_FILE="$(conda build --output conda/recipe)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Export release tag before resolving upload artifact path

The upload step calls conda build --output conda/recipe, but unlike the build/test steps it does not set GIT_DESCRIBE_TAG. Since conda/recipe/meta.yaml uses environ['GIT_DESCRIBE_TAG'] to compute the package version, this command fails in the upload step on every release run, preventing package publication.

Useful? React with 👍 / 👎.

ANACONDA_ORG="${ANACONDA_ORG:-opflow-dev}"
if [ -z "${ANACONDA_API_TOKEN:-}" ]; then
echo "Missing ANACONDA_API_TOKEN secret."
exit 1
fi
anaconda upload -u "$ANACONDA_ORG" "$PKG_FILE"
2 changes: 2 additions & 0 deletions conda/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ source:
build:
number: 0
skip: True # [win]
script_env:
- GIT_DESCRIBE_TAG

requirements:
build:
Expand Down
Loading