Skip to content

Add to conda-forge

Add to conda-forge #37

name: Add to conda-forge
on:
push:
workflow_dispatch:
inputs:
name:
type: string
description: PyPi package name
default: 'criclive'
github-username:
type: string
description: GitHub Username
default: 'aktech'
upstream-github-account:
type: string
description: Upstream github username (conda-forge)
default: 'aktech'
git-name:
type: string
description: Git config Name
default: 'Amit Kumar'
git-email:
type: string
description: Git config Email
default: 'dtu.amit@gmail.com'
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Set Inputs
id: set-inputs
run: |
input_package_name=${{ github.event.inputs.name }}
package_name=${input_package_name:-"criclive"}
timestamp=$(date +%s)
pr_branch=package_name-$timestamp
input_github_username=${{ github.event.inputs.github-username }}
github_username=${input_github_username:-"aktech"}
input_upstream_github_username=${{ github.event.inputs.upstream-github-account }}
upstream_github_username=${input_upstream_github_username:-"aktech"}
input_git_name="${{ github.event.inputs.git-name }}"
git_name=${input_git_name:-"Amit"}
input_git_email=${{ github.event.inputs.git-email }}
git_email=${input_git_email:-"dtu.amit@gmail.com"}
echo "package_name=$package_name" >> "$GITHUB_OUTPUT"
echo "pr_branch=$pr_branch" >> "$GITHUB_OUTPUT"
echo "gh_username=$github_username" >> "$GITHUB_OUTPUT"
echo "upstream_github_username=$upstream_github_username" >> "$GITHUB_OUTPUT"
echo "git_name=$git_name" >> "$GITHUB_OUTPUT"
echo "git_email=$git_email" >> "$GITHUB_OUTPUT"
- name: Get event type
run: |
echo ${{ github.event_name }}
- name: Setup Mamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.3.1-0'
environment-name: ci
init-shell: >-
bash
powershell
create-args: >-
python=3.10
grayskull
hub
- name: Clone staged-reciped
run: |
git clone https://github.com/conda-forge/staged-recipes
- name: Generate recipe for package using grayskull
run: |
grayskull pypi ${{ steps.set-inputs.outputs.package_name }}
ls -ltrh
ls ${{ steps.set-inputs.outputs.package_name }}/meta.yaml
- name: Move recipe to staged recipe
run: |
cp ${{ steps.set-inputs.outputs.package_name }} staged-recipes/recipes/ -r
ls staged-recipes/recipes/
- name: Add github username to meta.yaml
run: |
meta_yaml=staged-recipes/recipes/${{ steps.set-inputs.outputs.package_name }}/meta.yaml
sed -i 's/AddYourGitHubIdHere/${{ steps.set-inputs.outputs.gh_username }}/g' $meta_yaml
- name: Commit Recipe
run: |
cd staged-recipes
git add .
git status
git config --global user.email "${{ steps.set-inputs.outputs.git_email }}"
git config --global user.name "${{ steps.set-inputs.outputs.git_name }}"
git commit -m "Add recipe for ${{ steps.set-inputs.outputs.package_name }}"
- name: Add Fork remote
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
cd staged-recipes
git remote -v
github_username=${{ steps.set-inputs.outputs.gh_username }}
url=https://$github_username:$GH_TOKEN@github.com/$github_username/staged-recipes.git
git remote add fork $url
git remote -v
- name: Push recipe to the fork branch
run: |
cd staged-recipes
echo "Pushing recipe"
git checkout -b ${{ steps.set-inputs.outputs.pr_branch }}
git push fork
- name: Create a PR on conda-forge
if: github.event_name == 'workflow_dispatch'
run: |
echo "Creating a PR on conda-forge"
cd staged-recipes
branch=${{ steps.set-inputs.outputs.pr_branch }}
upstream_owner=${{ steps.set-inputs.outputs.upstream_github_username }}
hub pull-request -m "Add recipe for ${{ steps.set-inputs.outputs.package_name }}" --base $upstream_owner:main --head ${{ steps.set-inputs.outputs.gh_username }}:$branch
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}