Skip to content

build and push

build and push #127

name: build and push
description: build a conan package and push it to artifactory
on:
workflow_dispatch:
inputs:
package:
description: 'package name'
required: true
version:
description: 'package version'
required: true
conanfile_path:
description: 'the conanfile.py path of the package '
required: true
default: 'all/conanfile.py'
repository:
description: 'Choose Artifactory repository'
required: false
type: choice
options:
- production
- testing
default: 'testing'
user_channel:
description: 'define the user and channel for the package '
required: false
default: ''
extra_options:
description: 'extra conan options (e.g. -o pkg:opt=val -c conf=val)'
required: false
default: ''
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
CONAN_REVISIONS_ENABLED: 1
# the path of the conanfile.py
PACKAGE_RECIPE_PATH: ${{ github.event.inputs.package }}/${{ github.event.inputs.conanfile_path }}
# the package reference
PACKAGE_REF: ${{ github.event.inputs.package }}/${{ github.event.inputs.version }}@${{ github.event.inputs.user_channel }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install Conan
run: |
pip install --user conan==1.65.0
conan --version
- name: Configure Conan remote
run: |
conan remote remove conancenter
conan remote add default-conan-local https://milvus01.jfrog.io/artifactory/api/conan/default-conan-local
conan remote add testing https://milvus01.jfrog.io/artifactory/api/conan/testing
# make conancenter the lowest priority
conan remote add conancenter https://center.conan.io
- name: List remote Conan repositories
run: |
# List remote Conan repositories
conan remote list
- name: Export all local recipes
run: |
# Export all recipes in the repo so transitive deps can be resolved locally
for config in */config.yml; do
pkg_dir=$(dirname "$config")
pkg_name=$(basename "$pkg_dir")
recipe_path="$pkg_dir/all/conanfile.py"
if [ -f "$recipe_path" ]; then
# Read versions from config.yml and export each
python3 -c "
import yaml, sys
with open('$config') as f:
data = yaml.safe_load(f)
for ver in (data.get('versions') or {}):
print(ver)
" | while read -r ver; do
conan export "$recipe_path" "$pkg_name/$ver@" 2>/dev/null || true
done
fi
done
- name: build a package
run: |
conan create $PACKAGE_RECIPE_PATH $PACKAGE_REF \
--build=missing \
-s compiler=gcc \
-s compiler.version=11 \
-s compiler.libcxx=libstdc++11 \
-s compiler.cppstd=17 \
-s build_type=Release \
${{ github.event.inputs.extra_options }}
- name: inspect built package
run: |
conan search '*' --revisions
- name: Upload
run: |
# upload all packages
if [ "${{ github.event.inputs.repository }}" = "production" ]; then
conan user -p ${{ secrets.JFROG_PASSWORD }} -r default-conan-local ${{ secrets.JFROG_USERNAME }}
# upload to production repository
conan upload '*' -r default-conan-local -c
else
conan user -p ${{ secrets.JFROG_PASSWORD }} -r testing ${{ secrets.JFROG_USERNAME }}
# upload to testing repository
conan upload '*' -r testing -c
fi