Skip to content

attempt

attempt #25

Workflow file for this run

name: Conda Release to Anaconda.org
on:
push:
tags:
- 'v*.*.*'
jobs:
build-and-upload:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge, defaults
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
auto-update-conda: true
auto-activate-base: true
# 1) Check out the current repo (so we can access conda-recipe/)
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# 2) Install Miniconda and conda-build/anaconda-client
- name: create environment with conda
run: |
conda install -y conda-build anaconda-client
# 3) Determine VERSION (strip the leading “v”) and compute SHA256
- name: Set version and SHA256
id: vars
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# Download tarball for this tag and compute checksum
TAR_URL="https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/v${VERSION}.tar.gz"
echo "TAR_URL=$TAR_URL" >> $GITHUB_OUTPUT
curl -L $TAR_URL -o release.tar.gz
SHA256=$(sha256sum release.tar.gz | cut -d' ' -f1)
echo "SHA256=$SHA256" >> $GITHUB_OUTPUT
# Extract OWNER and REPO from GITHUB_REPOSITORY (format: owner/repo)
REPO_OWNER=${GITHUB_REPOSITORY%%/*}
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_OUTPUT
REPO_NAME=${GITHUB_REPOSITORY##*/}
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT
REPO_HOME="https://github.com/${GITHUB_REPOSITORY}"
echo "REPO_HOME=$REPO_HOME" >> $GITHUB_OUTPUT
echo "$GITHUB_OUTPUT"
# 4) Update meta.yaml with the correct version and sha256
- name: Patch conda-recipe/meta.yaml
run: |
cd conda-recipe
# Replace the Jinja “{% set name = "..." %}” line:
sed -i "s|^{% set name = \".*\" %}|{% set name = \"${{ steps.vars.outputs.REPO_NAME }}\" %}|" meta.yaml
# Replace the Jinja “{% set version = "..." %}” line:
sed -i "s|^{% set version = \".*\" %}|{% set version = \"${{ steps.vars.outputs.VERSION }}\" %}|" meta.yaml
# Update the source URL to use the real owner, repo, and version
# Original line looks like:
# url: <PLACEHOLDER>
sed -i "s|^ url: .*| url: ${{ steps.vars.outputs.TAR_URL }}|" meta.yaml
# Replace the “ sha256: ...” line (two‐space indentation under source:)
# Original line looks like:
# sha256: <PLACEHOLDER>
sed -i "s|^ sha256: .*| sha256: ${{ steps.vars.outputs.SHA256 }}|" meta.yaml
# Update the homepage URL to use the real owner and repo
# Original line looks like:
# home: <PLACEHOLDER>
sed -i "s|^ home: .*| home: ${{ steps.vars.outputs.REPO_HOME }}|" meta.yaml
cat meta.yaml
# 5) Build the conda package
- name: Build conda package
run: |
cd conda-recipe
conda-build . --output-folder ../conda-build-artifacts
# 6) Upload the built package to Anaconda.org
- name: Upload to Anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
PACKAGE=$(ls conda-build-artifacts/linux-64/cpp-python-tool-template-${{ steps.vars.outputs.VERSION }}-*.tar.bz2)
anaconda -t $ANACONDA_TOKEN upload $PACKAGE --user $ANACONDA_USER --label main --force