Update auto_bioconda_pr.yaml #7
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: Auto Bioconda PR with Test & meta.yaml generation (Manual Only) | ||
| on: | ||
| workflow_dispatch: | ||
| jobs: | ||
| bioconda_pr: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout this repo | ||
| uses: actions/checkout@v3 | ||
| - name: Extract version and package name using ast | ||
| id: vars | ||
| run: | | ||
| set -e | ||
| INIT_PATH=$(find . -type f -name '__init__.py' | head -n1) | ||
| echo "📄 Found __init__.py at: $INIT_PATH" | ||
| echo "import ast" > get_version.py | ||
| echo "with open('$INIT_PATH') as f:" >> get_version.py | ||
| echo " tree = ast.parse(f.read())" >> get_version.py | ||
| echo "for node in ast.walk(tree):" >> get_version.py | ||
| echo " if isinstance(node, ast.Assign) and getattr(node.targets[0], 'id', None) == '__version__':" >> get_version.py | ||
| echo " print(node.value.s)" >> get_version.py | ||
| echo " break" >> get_version.py | ||
| VERSION=$(python3 get_version.py) | ||
| PACKAGE=$(basename $(dirname "$INIT_PATH")) | ||
| if [ -z "$VERSION" ]; then | ||
| echo "❌ __version__ not found" | ||
| exit 1 | ||
| fi | ||
| echo "📦 PACKAGE: $PACKAGE" | ||
| echo "📌 VERSION: $VERSION" | ||
| echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
| echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV | ||
| - name: Generate meta.yaml in recipes/${{ env.PACKAGE }} | ||
| run: | | ||
| mkdir -p recipes/${PACKAGE} | ||
| cat <<'EOF' > recipes/${PACKAGE}/meta.yaml | ||
| {% set name = "{{ name }}" %} | ||
| {% set version = "{{ version }}" %} | ||
| package: | ||
| name: "{{ name|lower }}" | ||
| version: "{{ version }}" | ||
| source: | ||
| url: https://github.com/kamome1201/{{ name }}/archive/refs/tags/v{{ version }}.tar.gz | ||
| sha256: "TO_BE_REPLACED" | ||
| build: | ||
| number: 0 | ||
| noarch: python | ||
| script: "{{ PYTHON }} -m pip install . -vv --ignore-installed --no-deps" | ||
| requirements: | ||
| host: | ||
| - python >=3.8 | ||
| - pip | ||
| - setuptools | ||
| - wheel | ||
| run: | ||
| - python >=3.8 | ||
| test: | ||
| imports: | ||
| - {{ name }} | ||
| about: | ||
| home: "https://github.com/kfuku52/{{ name }}" | ||
| license: "BSD-3-Clause" | ||
| license_file: "LICENSE" | ||
| summary: "Short summary of what {{ name }} does." | ||
| EOF | ||
| - name: Download source archive and compute SHA256 | ||
| run: | | ||
| url="https://github.com/kamome1201/${PACKAGE}/archive/refs/tags/v${VERSION}.tar.gz" | ||
| wget -O source.tar.gz "$url" | ||
| SHA256=$(sha256sum source.tar.gz | awk '{print $1}') | ||
| echo "SHA256=$SHA256" >> $GITHUB_ENV | ||
| - name: Clone your fork of bioconda-recipes | ||
| run: | | ||
| git clone https://github.com/kamome1201/bioconda-recipes.git | ||
| cd bioconda-recipes | ||
| git remote add upstream https://github.com/bioconda/bioconda-recipes.git | ||
| git fetch upstream | ||
| git checkout -B add-${PACKAGE}-${VERSION} upstream/master | ||
| - name: Copy recipe into bioconda-recipes | ||
| run: | | ||
| cp -r recipes/${PACKAGE} bioconda-recipes/recipes/ | ||
| - name: Replace sha256 in meta.yaml | ||
| run: | | ||
| sed -i "s|sha256: .*|sha256: \"${SHA256}\"|" bioconda-recipes/recipes/${PACKAGE}/meta.yaml | ||
| - name: Create config.yml for bioconda-utils | ||
| run: | | ||
| cat <<EOF > bioconda-recipes/config.yml | ||
| channels: | ||
| - bioconda | ||
| - conda-forge | ||
| - defaults | ||
| EOF | ||
| - name: Check copied recipe contents | ||
| run: | | ||
| ls -R bioconda-recipes/recipes/${PACKAGE} | ||
| - name: Run lint + build + test with bioconda-utils (Docker) | ||
| run: | | ||
| ABS_PATH=$(realpath bioconda-recipes) | ||
| docker run --rm -v $ABS_PATH:/bioconda-recipes \ | ||
| quay.io/bioconda/bioconda-utils-build-env \ | ||
| bash -c "cd /bioconda-recipes && bioconda-utils build recipes config.yml --packages ${PACKAGE} --loglevel info --docker --git-range master" | ||
| # 以下のステップは一時的にコメントアウトされています(必要時に有効化してください) | ||
| # - name: Commit and push | ||
| # run: | | ||
| # cd bioconda-recipes | ||
| # git config user.name "github-actions" | ||
| # git config user.email "[email protected]" | ||
| # git add recipes/${PACKAGE} | ||
| # git commit -m "Add ${PACKAGE} v${VERSION} [auto-generated]" | ||
| # git push origin add-${PACKAGE}-${VERSION} | ||
| # - name: Create Pull Request | ||
| # uses: peter-evans/create-pull-request@v5 | ||
| # with: | ||
| # token: ${{ secrets.GH_PAT }} | ||
| # title: "Add ${PACKAGE} recipe v${{ env.VERSION }}" | ||
| # commit-message: "Auto PR: ${PACKAGE} v${{ env.VERSION }}" | ||
| # base: master | ||
| # branch: add-${PACKAGE}-${{ env.VERSION }} | ||
| # body: | | ||
| # This PR was automatically generated by GitHub Actions. | ||
| # - **Package**: ${{ env.PACKAGE }} | ||
| # - **Version**: v${{ env.VERSION }} | ||
| # - **SHA256**: ${{ env.SHA256 }} | ||