|
| 1 | +--- |
| 2 | +# .github/workflows/build-conda.yml |
| 3 | +name: Build and Upload Conda Package |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [integrate-conda] |
| 7 | + workflow_dispatch: |
| 8 | +jobs: |
| 9 | + build-and-upload: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout repository |
| 13 | + uses: actions/checkout@v4 |
| 14 | + - name: Cache conda build cache |
| 15 | + uses: actions/cache@v3 |
| 16 | + with: |
| 17 | + path: /home/runner/miniconda3/conda-bld |
| 18 | + key: ${{ runner.os }}-conda-bld-${{ hashFiles('recipe/meta.yaml') }} |
| 19 | + restore-keys: | |
| 20 | + ${{ runner.os }}-conda-bld- |
| 21 | + - name: Setup Miniforge and mamba |
| 22 | + uses: conda-incubator/setup-miniconda@v3 |
| 23 | + with: |
| 24 | + miniforge-variant: Miniforge3 |
| 25 | + miniforge-version: latest |
| 26 | + mamba-version: '*' |
| 27 | + use-mamba: true |
| 28 | + conda-solver: libmamba |
| 29 | + auto-activate-base: true |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + mamba install -y -c conda-forge conda-build anaconda-client boa |
| 33 | + - name: Get latest commit SHA from integrate-conda branch |
| 34 | + id: get_sha |
| 35 | + run: | |
| 36 | + echo "Fetching latest commit on integrate-conda branch..." |
| 37 | + COMMIT_SHA=$(git ls-remote origin refs/heads/integrate-conda | cut -f1) |
| 38 | + echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV |
| 39 | + - name: Update meta.yaml with latest ref and sha256 |
| 40 | + run: | |
| 41 | + echo "Updating meta.yaml with commit: $COMMIT_SHA" |
| 42 | +
|
| 43 | + # 1) Update the Jinja-set 'ref' (this is fine) |
| 44 | + sed -i "s|^{% set ref = \".*\" %}|{% set ref = \"$COMMIT_SHA\" %}|" ./recipe/meta.yaml |
| 45 | +
|
| 46 | + # 2) Download the tarball and compute the checksum |
| 47 | + curl -L -o source.tar.gz \ |
| 48 | + https://github.com/khanlab/labelmerge/archive/${COMMIT_SHA}.tar.gz |
| 49 | + SHA256_SUM=$(sha256sum source.tar.gz | awk '{print $1}') |
| 50 | + echo "New sha256: $SHA256_SUM" |
| 51 | +
|
| 52 | + # 3) Replace the literal 'sha256:' line under source: |
| 53 | + sed -i "s|^\(\s*sha256:\s*\).*|\1$SHA256_SUM|" ./recipe/meta.yaml |
| 54 | + - name: Build & capture path |
| 55 | + id: build |
| 56 | + run: | |
| 57 | + cd recipe |
| 58 | + OUT=$(conda build . -c conda-forge -c bioconda --output 2>/dev/null) |
| 59 | + echo "PACKAGE_PATH=$OUT" >> $GITHUB_ENV |
| 60 | + conda mambabuild . -c conda-forge -c bioconda |
| 61 | + - name: Upload package to Khanlab channel |
| 62 | + shell: bash -l {0} |
| 63 | + run: |- |
| 64 | + conda activate base |
| 65 | + anaconda login \ |
| 66 | + --username ${{ secrets.ANACONDA_USERNAME }} \ |
| 67 | + --password ${{ secrets.ANACONDA_PASSWORD }} |
| 68 | + anaconda upload "$PACKAGE_PATH" \ |
| 69 | + --label main \ |
| 70 | + --force \ |
0 commit comments