|
| 1 | +name: UniLabOS Conda Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, dev] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + branches: [main, dev] |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + upload_to_anaconda: |
| 12 | + description: '是否上传到Anaconda.org' |
| 13 | + required: false |
| 14 | + default: false |
| 15 | + type: boolean |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + defaults: |
| 22 | + run: |
| 23 | + shell: bash -l {0} |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Setup Miniconda |
| 31 | + uses: conda-incubator/setup-miniconda@v3 |
| 32 | + with: |
| 33 | + miniconda-version: 'latest' |
| 34 | + channels: conda-forge,robostack-staging,uni-lab,defaults |
| 35 | + channel-priority: strict |
| 36 | + activate-environment: build-env |
| 37 | + auto-activate-base: false |
| 38 | + auto-update-conda: false |
| 39 | + show-channel-urls: true |
| 40 | + |
| 41 | + - name: Install rattler-build and anaconda-client |
| 42 | + run: | |
| 43 | + conda install -c conda-forge rattler-build anaconda-client |
| 44 | +
|
| 45 | + - name: Show environment info |
| 46 | + run: | |
| 47 | + conda info |
| 48 | + conda list | grep -E "(rattler-build|anaconda-client)" |
| 49 | + echo "Building UniLabOS package" |
| 50 | +
|
| 51 | + - name: Build conda package |
| 52 | + run: | |
| 53 | + rattler-build build -r .conda/recipe.yaml -c uni-lab -c robostack-staging -c conda-forge |
| 54 | +
|
| 55 | + - name: List built packages |
| 56 | + run: | |
| 57 | + echo "Built packages in output directory:" |
| 58 | + find ./output -name "*.conda" | head -10 |
| 59 | + ls -la ./output/noarch/ || echo "noarch directory not found" |
| 60 | + echo "Output directory structure:" |
| 61 | + find ./output -type f -name "*.conda" |
| 62 | +
|
| 63 | + - name: Prepare artifacts for upload |
| 64 | + run: | |
| 65 | + mkdir -p conda-packages-temp |
| 66 | + find ./output -name "*.conda" -exec cp {} conda-packages-temp/ \; |
| 67 | + echo "Copied files to temp directory:" |
| 68 | + ls -la conda-packages-temp/ |
| 69 | +
|
| 70 | + - name: Upload conda package artifacts |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: conda-package-unilabos |
| 74 | + path: conda-packages-temp |
| 75 | + if-no-files-found: warn |
| 76 | + retention-days: 30 |
| 77 | + |
| 78 | + - name: Login to Anaconda with API token |
| 79 | + if: github.event.inputs.upload_to_anaconda == 'true' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') |
| 80 | + run: | |
| 81 | + anaconda login --token ${{ secrets.ANACONDA_API_TOKEN }} |
| 82 | +
|
| 83 | + - name: Upload to Anaconda.org (uni-lab organization) |
| 84 | + if: github.event.inputs.upload_to_anaconda == 'true' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') |
| 85 | + run: | |
| 86 | + for package in $(find ./output -name "*.conda"); do |
| 87 | + echo "Uploading $package to uni-lab organization..." |
| 88 | + anaconda upload --user uni-lab --force "$package" |
| 89 | + done |
| 90 | +
|
| 91 | + - name: Logout from Anaconda |
| 92 | + if: always() && (github.event.inputs.upload_to_anaconda == 'true' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) |
| 93 | + run: | |
| 94 | + anaconda logout || true |
0 commit comments