|
| 1 | +name: Conda Release to Anaconda.org |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-and-upload: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + # 1) Check out the current repo (so we can access conda-recipe/) |
| 14 | + - name: Check out repository |
| 15 | + uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + # 2) Install Miniconda and conda-build/anaconda-client |
| 20 | + - name: Install Miniconda and tools |
| 21 | + run: | |
| 22 | + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh |
| 23 | + bash miniconda.sh -b -p $HOME/miniconda |
| 24 | + eval "$($HOME/miniconda/bin/conda shell.bash hook)" |
| 25 | + conda install -y conda-build anaconda-client |
| 26 | +
|
| 27 | + # 3) Determine VERSION (strip the leading “v”) and compute SHA256 |
| 28 | + - name: Set version and SHA256 |
| 29 | + id: vars |
| 30 | + run: | |
| 31 | + VERSION=${GITHUB_REF_NAME#v} |
| 32 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 33 | + # Download tarball for this tag and compute checksum |
| 34 | + TAR_URL="https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/v${VERSION}.tar.gz" |
| 35 | + curl -L $TAR_URL -o release.tar.gz |
| 36 | + SHA256=$(sha256sum release.tar.gz | cut -d' ' -f1) |
| 37 | + echo "SHA256=$SHA256" >> $GITHUB_OUTPUT |
| 38 | +
|
| 39 | + # 4) Update meta.yaml with the correct version and sha256 |
| 40 | + - name: Patch conda-recipe/meta.yaml |
| 41 | + run: | |
| 42 | + cd conda-recipe |
| 43 | + sed -i "s/^ version: .*/ version: ${{ steps.vars.outputs.VERSION }}/" meta.yaml |
| 44 | + sed -i "s/^ sha256: .*/ sha256: ${{ steps.vars.outputs.SHA256 }}/" meta.yaml |
| 45 | +
|
| 46 | + # 5) Build the conda package |
| 47 | + - name: Build conda package |
| 48 | + run: | |
| 49 | + eval "$($HOME/miniconda/bin/conda shell.bash hook)" |
| 50 | + cd conda-recipe |
| 51 | + conda-build . --output-folder ../conda-build-artifacts |
| 52 | +
|
| 53 | + # 6) Upload the built package to Anaconda.org |
| 54 | + - name: Upload to Anaconda.org |
| 55 | + env: |
| 56 | + ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} |
| 57 | + run: | |
| 58 | + eval "$($HOME/miniconda/bin/conda shell.bash hook)" |
| 59 | + PACKAGE=$(ls conda-build-artifacts/linux-64/aligncount-demo-${{ steps.vars.outputs.VERSION }}-*.tar.bz2) |
| 60 | + anaconda -t $ANACONDA_TOKEN upload $PACKAGE --user $ANACONDA_USER --label main --force |
0 commit comments