name: Multi-Platform Conda Build on: # 在 CI Check 工作流完成后触发(仅限 main/dev 分支) workflow_run: workflows: ["CI Check"] types: - completed branches: [main, dev] # 支持 tag 推送(不依赖 CI Check) push: tags: ['v*'] # 手动触发 workflow_dispatch: inputs: platforms: description: '选择构建平台 (逗号分隔): linux-64, osx-64, osx-arm64, win-64' required: false default: 'osx-arm64' upload_to_anaconda: description: '是否上传到Anaconda.org' required: false default: false type: boolean skip_ci_check: description: '跳过等待 CI Check (手动触发时可选)' required: false default: false type: boolean jobs: # 等待 CI Check 完成的 job (仅用于 workflow_run 触发) wait-for-ci: runs-on: ubuntu-latest if: github.event_name == 'workflow_run' outputs: should_continue: ${{ steps.check.outputs.should_continue }} steps: - name: Check CI status id: check run: | if [[ "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then echo "should_continue=true" >> $GITHUB_OUTPUT echo "CI Check passed, proceeding with build" else echo "should_continue=false" >> $GITHUB_OUTPUT echo "CI Check did not succeed (status: ${{ github.event.workflow_run.conclusion }}), skipping build" fi build: needs: [wait-for-ci] # 运行条件:workflow_run 触发且 CI 成功,或者其他触发方式 if: | always() && (needs.wait-for-ci.result == 'skipped' || needs.wait-for-ci.outputs.should_continue == 'true') strategy: fail-fast: false matrix: include: - os: ubuntu-latest platform: linux-64 env_file: unilabos-linux-64.yaml - os: macos-15 # Intel (via Rosetta) platform: osx-64 env_file: unilabos-osx-64.yaml - os: macos-latest # ARM64 platform: osx-arm64 env_file: unilabos-osx-arm64.yaml - os: windows-latest platform: win-64 env_file: unilabos-win64.yaml runs-on: ${{ matrix.os }} defaults: run: shell: bash -l {0} steps: - uses: actions/checkout@v4 with: # 如果是 workflow_run 触发,使用触发 CI Check 的 commit ref: ${{ github.event.workflow_run.head_sha || github.ref }} fetch-depth: 0 - name: Check if platform should be built id: should_build run: | if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then echo "should_build=true" >> $GITHUB_OUTPUT elif [[ -z "${{ github.event.inputs.platforms }}" ]]; then echo "should_build=true" >> $GITHUB_OUTPUT elif [[ "${{ github.event.inputs.platforms }}" == *"${{ matrix.platform }}"* ]]; then echo "should_build=true" >> $GITHUB_OUTPUT else echo "should_build=false" >> $GITHUB_OUTPUT fi - name: Setup Miniconda if: steps.should_build.outputs.should_build == 'true' uses: conda-incubator/setup-miniconda@v3 with: miniconda-version: 'latest' channels: conda-forge,robostack-staging,defaults channel-priority: strict activate-environment: build-env auto-update-conda: false show-channel-urls: true - name: Install rattler-build and anaconda-client if: steps.should_build.outputs.should_build == 'true' run: | conda install -c conda-forge rattler-build anaconda-client - name: Show environment info if: steps.should_build.outputs.should_build == 'true' run: | conda info conda list | grep -E "(rattler-build|anaconda-client)" echo "Platform: ${{ matrix.platform }}" echo "OS: ${{ matrix.os }}" - name: Build conda package if: steps.should_build.outputs.should_build == 'true' run: | if [[ "${{ matrix.platform }}" == "osx-arm64" ]]; then rattler-build build -r ./recipes/msgs/recipe.yaml -c robostack -c robostack-staging -c conda-forge else rattler-build build -r ./recipes/msgs/recipe.yaml -c robostack -c robostack-staging -c conda-forge fi - name: List built packages if: steps.should_build.outputs.should_build == 'true' run: | echo "Built packages in output directory:" find ./output -name "*.conda" | head -10 ls -la ./output/${{ matrix.platform }}/ || echo "${{ matrix.platform }} directory not found" ls -la ./output/noarch/ || echo "noarch directory not found" echo "Output directory structure:" find ./output -type f -name "*.conda" - name: Prepare artifacts for upload if: steps.should_build.outputs.should_build == 'true' run: | mkdir -p conda-packages-temp find ./output -name "*.conda" -exec cp {} conda-packages-temp/ \; echo "Copied files to temp directory:" ls -la conda-packages-temp/ - name: Upload conda package artifacts if: steps.should_build.outputs.should_build == 'true' uses: actions/upload-artifact@v6 with: name: conda-package-${{ matrix.platform }} path: conda-packages-temp if-no-files-found: warn retention-days: 30 - name: Upload to Anaconda.org (unilab organization) if: steps.should_build.outputs.should_build == 'true' && github.event.inputs.upload_to_anaconda == 'true' run: | for package in $(find ./output -name "*.conda"); do echo "Uploading $package to unilab organization..." anaconda -t ${{ secrets.ANACONDA_API_TOKEN }} upload --user uni-lab --force "$package" done