fix variant #23
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: build-and-publish-channel | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "recipe/**" | |
| - "scripts/ci/**" | |
| - ".github/workflows/**" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| # detect changed targets | |
| detect: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| has_changes: ${{ steps.set-matrix.outputs.has_changes }} | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Compute changed targets | |
| id: set-matrix | |
| env: | |
| RECIPE_ROOT: "recipe" | |
| EVENT_NAME: ${{ github.event_name }} | |
| BEFORE_SHA: ${{ github.event.before }} | |
| HEAD_SHA: ${{ github.sha }} | |
| GITHUB_SHA: ${{ github.sha }} | |
| run: python scripts/ci/detect_changed_targets.py | |
| # build | |
| build: | |
| needs: detect | |
| if: needs.detect.outputs.has_changes == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.detect.outputs.matrix) }} | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v4 | |
| - name: Build package | |
| uses: prefix-dev/rattler-build-action@v0.2.34 | |
| with: | |
| recipe-path: ${{ matrix.recipe }} | |
| artifact-name: packages-${{ matrix.target }}-${{ matrix.target_platform }} | |
| build-args: "--target-platform ${{ matrix.target_platform }} --output-dir build_artifacts" | |
| upload-artifact: false | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: packages-${{ matrix.target }}-${{ matrix.target_platform }} | |
| path: | | |
| build_artifacts/${{ matrix.target_platform }}/*.conda | |
| build_artifacts/${{ matrix.target_platform }}/*.tar.bz2 | |
| if-no-files-found: error | |
| # publish to channel | |
| publish: | |
| needs: [detect, build] | |
| if: ${{ github.ref == 'refs/heads/main' && needs.detect.outputs.has_changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v4 | |
| - name: Check gh-pages branch | |
| id: gh_pages | |
| run: | | |
| if git ls-remote --exit-code --heads origin gh-pages > /dev/null; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout existing channel | |
| if: steps.gh_pages.outputs.exists == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: channel | |
| fetch-depth: 1 | |
| - name: Ensure channel directory | |
| run: mkdir -p channel | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| pattern: packages-* | |
| - name: Setup micromamba | |
| uses: mamba-org/setup-micromamba@v2 | |
| with: | |
| environment-name: conda-index | |
| create-args: >- | |
| -c conda-forge | |
| python=3.12 | |
| conda-index | |
| - name: Run Publish Script | |
| env: | |
| CHANNEL_DIR: channel | |
| ARTIFACTS_DIR: artifacts | |
| CONDA_INDEX_THREADS: "4" | |
| CONDA_INDEX_CMD: "micromamba run -n conda-index python -m conda_index" | |
| run: python scripts/ci/publish_channel.py | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: channel | |
| publish_branch: gh-pages | |
| commit_message: "Deploy channel: update packages [skip ci]" | |
| force_orphan: true |