|
| 1 | +name: Auto Bioconda PR with Test & meta.yaml generation (Manual Only) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + bioconda_pr: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Checkout this repo |
| 12 | + uses: actions/checkout@v3 |
| 13 | + |
| 14 | + - name: Extract version and package name using ast |
| 15 | + id: vars |
| 16 | + run: | |
| 17 | + set -e |
| 18 | +
|
| 19 | + INIT_PATH=$(find . -type f -name '__init__.py' | head -n1) |
| 20 | + echo "📄 Found __init__.py at: $INIT_PATH" |
| 21 | +
|
| 22 | + echo 'import ast' > get_version.py |
| 23 | + echo 'with open("'$INIT_PATH'") as f:' >> get_version.py |
| 24 | + echo ' tree = ast.parse(f.read())' >> get_version.py |
| 25 | + echo 'for node in ast.walk(tree):' >> get_version.py |
| 26 | + echo ' if isinstance(node, ast.Assign):' >> get_version.py |
| 27 | + echo ' if getattr(node.targets[0], "id", None) == "__version__":' >> get_version.py |
| 28 | + echo ' print(node.value.s)' >> get_version.py |
| 29 | + echo ' break' >> get_version.py |
| 30 | +
|
| 31 | + VERSION=$(python3 get_version.py) |
| 32 | + PACKAGE=$(basename $(dirname "$INIT_PATH")) |
| 33 | +
|
| 34 | + if [ -z "$VERSION" ]; then |
| 35 | + echo "❌ __version__ not found in $INIT_PATH" |
| 36 | + cat "$INIT_PATH" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | +
|
| 40 | + echo "📦 PACKAGE: $PACKAGE" |
| 41 | + echo "📌 VERSION: $VERSION" |
| 42 | +
|
| 43 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 44 | + echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV |
| 45 | +
|
| 46 | + - name: Generate meta.yaml in recipes/${PACKAGE} |
| 47 | + run: | |
| 48 | + mkdir -p recipes/${PACKAGE} |
| 49 | + echo "{% set name = \"${PACKAGE}\" %}" > recipes/${PACKAGE}/meta.yaml |
| 50 | + echo "{% set version = \"${VERSION}\" %}" >> recipes/${PACKAGE}/meta.yaml |
| 51 | + echo "" >> recipes/${PACKAGE}/meta.yaml |
| 52 | + echo "package:" >> recipes/${PACKAGE}/meta.yaml |
| 53 | + echo " name: \"{{ name|lower }}\"" >> recipes/${PACKAGE}/meta.yaml |
| 54 | + echo " version: \"{{ version }}\"" >> recipes/${PACKAGE}/meta.yaml |
| 55 | + echo "" >> recipes/${PACKAGE}/meta.yaml |
| 56 | + echo "source:" >> recipes/${PACKAGE}/meta.yaml |
| 57 | + echo " url: https://github.com/kamome1201/${PACKAGE}/archive/refs/tags/v{{ version }}.tar.gz" >> recipes/${PACKAGE}/meta.yaml |
| 58 | + echo " sha256: \"TO_BE_REPLACED\"" >> recipes/${PACKAGE}/meta.yaml |
| 59 | + echo "" >> recipes/${PACKAGE}/meta.yaml |
| 60 | + echo "build:" >> recipes/${PACKAGE}/meta.yaml |
| 61 | + echo " number: 0" >> recipes/${PACKAGE}/meta.yaml |
| 62 | + echo " noarch: python" >> recipes/${PACKAGE}/meta.yaml |
| 63 | + echo " script: \"{{ PYTHON }} -m pip install . -vv --ignore-installed --no-deps\"" >> recipes/${PACKAGE}/meta.yaml |
| 64 | + echo "" >> recipes/${PACKAGE}/meta.yaml |
| 65 | + echo "requirements:" >> recipes/${PACKAGE}/meta.yaml |
| 66 | + echo " host:" >> recipes/${PACKAGE}/meta.yaml |
| 67 | + echo " - python >=3.8" >> recipes/${PACKAGE}/meta.yaml |
| 68 | + echo " - pip" >> recipes/${PACKAGE}/meta.yaml |
| 69 | + echo " - setuptools" >> recipes/${PACKAGE}/meta.yaml |
| 70 | + echo " - wheel" >> recipes/${PACKAGE}/meta.yaml |
| 71 | + echo " run:" >> recipes/${PACKAGE}/meta.yaml |
| 72 | + echo " - python >=3.8" >> recipes/${PACKAGE}/meta.yaml |
| 73 | + echo "" >> recipes/${PACKAGE}/meta.yaml |
| 74 | + echo "test:" >> recipes/${PACKAGE}/meta.yaml |
| 75 | + echo " imports:" >> recipes/${PACKAGE}/meta.yaml |
| 76 | + echo " - ${PACKAGE}" >> recipes/${PACKAGE}/meta.yaml |
| 77 | + echo "" >> recipes/${PACKAGE}/meta.yaml |
| 78 | + echo "about:" >> recipes/${PACKAGE}/meta.yaml |
| 79 | + echo " home: \"https://github.com/kfuku52/${PACKAGE}\"" >> recipes/${PACKAGE}/meta.yaml |
| 80 | + echo " license: \"BSD-3-Clause\"" >> recipes/${PACKAGE}/meta.yaml |
| 81 | + echo " license_file: \"LICENSE\"" >> recipes/${PACKAGE}/meta.yaml |
| 82 | + SUMMARY=$(head -n 1 README.md | sed 's/"/\\"/g') |
| 83 | + echo " summary: \"${SUMMARY}\"" >> recipes/${PACKAGE}/meta.yaml |
| 84 | +
|
| 85 | + - name: Download source archive and compute SHA256 |
| 86 | + run: | |
| 87 | + url="https://github.com/kamome1201/${PACKAGE}/archive/refs/tags/v${VERSION}.tar.gz" |
| 88 | + wget -O source.tar.gz "$url" |
| 89 | + sha256=$(sha256sum source.tar.gz | awk '{print $1}') |
| 90 | + echo "SHA256=$sha256" >> $GITHUB_ENV |
| 91 | + echo "SHA256=$sha256" # ← ログ確認用に追加 |
| 92 | +
|
| 93 | + - name: Clone your fork of bioconda-recipes |
| 94 | + run: | |
| 95 | + git clone https://github.com/kamome1201/bioconda-recipes.git |
| 96 | + cd bioconda-recipes |
| 97 | + git remote add upstream https://github.com/bioconda/bioconda-recipes.git |
| 98 | + git fetch upstream |
| 99 | +
|
| 100 | + - name: Create new branch |
| 101 | + run: | |
| 102 | + cd bioconda-recipes |
| 103 | + git checkout -b add-${PACKAGE}-${VERSION} |
| 104 | +
|
| 105 | + - name: Copy recipe into bioconda-recipes |
| 106 | + run: | |
| 107 | + cp -r recipes/${PACKAGE} bioconda-recipes/recipes/ |
| 108 | +
|
| 109 | + - name: Replace sha256 in meta.yaml |
| 110 | + run: | |
| 111 | + sed -i "s/sha256: .*/sha256: \"${{ env.SHA256 }}\"/" bioconda-recipes/recipes/${PACKAGE}/meta.yaml |
| 112 | +
|
| 113 | + - name: Create config.yml for bioconda-utils |
| 114 | + run: | |
| 115 | + echo "channels:" > bioconda-recipes/config.yml |
| 116 | + echo " - bioconda" >> bioconda-recipes/config.yml |
| 117 | + echo " - conda-forge" >> bioconda-recipes/config.yml |
| 118 | + echo " - defaults" >> bioconda-recipes/config.yml |
| 119 | +
|
| 120 | + - name: Check copied recipe contents |
| 121 | + run: | |
| 122 | + ls -R bioconda-recipes/recipes |
| 123 | +
|
| 124 | + - name: Run lint + build + test with bioconda-utils (Docker) |
| 125 | + run: | |
| 126 | + ABS_PATH=$(realpath bioconda-recipes) |
| 127 | + docker run --rm -v $ABS_PATH:/bioconda-recipes \ |
| 128 | + quay.io/bioconda/bioconda-utils-build-env \ |
| 129 | + bioconda-utils build recipes config.yml --packages ${PACKAGE} --loglevel info --docker --git-range master |
| 130 | +
|
| 131 | +# - name: Commit and push |
| 132 | +# run: | |
| 133 | +# cd bioconda-recipes |
| 134 | +# git add recipes/${PACKAGE} |
| 135 | +# git commit -m "Update ${PACKAGE} recipe to v$VERSION" |
| 136 | +# git push origin add-${PACKAGE}-${VERSION} |
| 137 | + |
| 138 | +# - name: Create Pull Request |
| 139 | +# uses: peter-evans/create-pull-request@v5 |
| 140 | +# with: |
| 141 | +# token: ${{ secrets.GH_PAT }} |
| 142 | +# title: "Update ${PACKAGE} recipe to v${{ env.VERSION }}" |
| 143 | +# commit-message: "Auto PR for Bioconda: ${PACKAGE} v${{ env.VERSION }}" |
| 144 | +# base: master |
| 145 | +# branch: add-${PACKAGE}-${{ env.VERSION }} |
| 146 | +# body: | |
| 147 | +# This PR was automatically generated by GitHub Actions. |
| 148 | +# - Package: ${{ env.PACKAGE }} |
| 149 | +# - Version: v${{ env.VERSION }} |
| 150 | +# - sha256: ${{ env.SHA256 }} |
0 commit comments