Skip to content

Commit 41f29cc

Browse files
authored
Update bioconda_pr.yaml
1 parent 613e68e commit 41f29cc

File tree

1 file changed

+82
-96
lines changed

1 file changed

+82
-96
lines changed

.github/workflows/bioconda_pr.yaml

Lines changed: 82 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -15,148 +15,134 @@ jobs:
1515
id: vars
1616
run: |
1717
set -e
18-
1918
INIT_PATH=$(find . -type f -name '__init__.py' | head -n1)
2019
echo "📄 Found __init__.py at: $INIT_PATH"
2120
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)
21+
python3 - <<EOF > .version.tmp
22+
import ast
23+
with open("$INIT_PATH") as f:
24+
tree = ast.parse(f.read())
25+
for node in ast.walk(tree):
26+
if isinstance(node, ast.Assign) and getattr(node.targets[0], "id", None) == "__version__":
27+
print(node.value.s)
28+
break
29+
EOF
30+
31+
VERSION=$(cat .version.tmp)
3232
PACKAGE=$(basename $(dirname "$INIT_PATH"))
3333

3434
if [ -z "$VERSION" ]; then
35-
echo "❌ __version__ not found in $INIT_PATH"
36-
cat "$INIT_PATH"
35+
echo "❌ __version__ not found"
3736
exit 1
3837
fi
3938

4039
echo "📦 PACKAGE: $PACKAGE"
4140
echo "📌 VERSION: $VERSION"
42-
4341
echo "VERSION=$VERSION" >> $GITHUB_ENV
4442
echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV
4543

46-
- name: Generate meta.yaml in recipes/${PACKAGE}
44+
- name: Generate meta.yaml in recipes/${{ env.PACKAGE }}
4745
run: |
4846
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-
echo " summary: \"Short summary of what ${PACKAGE} does.\"" >> recipes/${PACKAGE}/meta.yaml
47+
cat <<EOF > recipes/${PACKAGE}/meta.yaml
48+
{% set name = "${PACKAGE}" %}
49+
{% set version = "${VERSION}" %}
50+
51+
package:
52+
name: "{{ name|lower }}"
53+
version: "{{ version }}"
54+
55+
source:
56+
url: https://github.com/kamome1201/${PACKAGE}/archive/refs/tags/v{{ version }}.tar.gz
57+
sha256: "TO_BE_REPLACED"
58+
59+
build:
60+
number: 0
61+
noarch: python
62+
script: "{{ PYTHON }} -m pip install . -vv --ignore-installed --no-deps"
63+
64+
requirements:
65+
host:
66+
- python >=3.8
67+
- pip
68+
- setuptools
69+
- wheel
70+
run:
71+
- python >=3.8
72+
73+
test:
74+
imports:
75+
- ${PACKAGE}
76+
77+
about:
78+
home: "https://github.com/kfuku52/${PACKAGE}"
79+
license: "BSD-3-Clause"
80+
license_file: "LICENSE"
81+
summary: "Short summary of what ${PACKAGE} does."
82+
EOF
8383

8484
- name: Download source archive and compute SHA256
8585
run: |
8686
url="https://github.com/kamome1201/${PACKAGE}/archive/refs/tags/v${VERSION}.tar.gz"
8787
wget -O source.tar.gz "$url"
88-
sha256=$(sha256sum source.tar.gz | awk '{print $1}')
89-
echo "SHA256=$sha256" >> $GITHUB_ENV
88+
SHA256=$(sha256sum source.tar.gz | awk '{print $1}')
89+
echo "SHA256=$SHA256" >> $GITHUB_ENV
9090
9191
- name: Clone your fork of bioconda-recipes
9292
run: |
9393
git clone https://github.com/kamome1201/bioconda-recipes.git
9494
cd bioconda-recipes
9595
git remote add upstream https://github.com/bioconda/bioconda-recipes.git
9696
git fetch upstream
97-
git checkout -b add-${PACKAGE}-${VERSION} upstream/master
98-
99-
- name: Create new branch
100-
run: |
101-
cd bioconda-recipes
102-
git checkout -b add-${PACKAGE}-${VERSION}
97+
git checkout -B add-${PACKAGE}-${VERSION} upstream/master
10398
10499
- name: Copy recipe into bioconda-recipes
105100
run: |
106101
cp -r recipes/${PACKAGE} bioconda-recipes/recipes/
107102
108103
- name: Replace sha256 in meta.yaml
109104
run: |
110-
sed -i "s/sha256: .*/sha256: \"${SHA256}\"/" bioconda-recipes/recipes/${PACKAGE}/meta.yaml
105+
sed -i "s|sha256: .*|sha256: \"${SHA256}\"|" bioconda-recipes/recipes/${PACKAGE}/meta.yaml
111106
112107
- name: Create config.yml for bioconda-utils
113108
run: |
114-
echo "channels:" > bioconda-recipes/config.yml
115-
echo " - bioconda" >> bioconda-recipes/config.yml
116-
echo " - conda-forge" >> bioconda-recipes/config.yml
117-
echo " - defaults" >> bioconda-recipes/config.yml
109+
cat <<EOF > bioconda-recipes/config.yml
110+
channels:
111+
- bioconda
112+
- conda-forge
113+
- defaults
114+
EOF
118115

119116
- name: Check copied recipe contents
120117
run: |
121-
ls -R bioconda-recipes/recipes
122-
123-
- name: Check if recipe was copied correctly
124-
run: |
125-
if [ ! -d bioconda-recipes/recipes/${PACKAGE} ]; then
126-
echo "❌ Recipe folder not found!"
127-
ls -R bioconda-recipes/recipes
128-
exit 1
129-
fi
130-
118+
ls -R bioconda-recipes/recipes/${PACKAGE}
119+
131120
- name: Run lint + build + test with bioconda-utils (Docker)
132121
run: |
133122
ABS_PATH=$(realpath bioconda-recipes)
134123
docker run --rm -v $ABS_PATH:/bioconda-recipes \
135124
quay.io/bioconda/bioconda-utils-build-env \
136125
bash -c "cd /bioconda-recipes && bioconda-utils build recipes config.yml --packages ${PACKAGE} --loglevel info --docker --git-range master"
137126
138-
- name: Show recipe and config path inside container
127+
- name: Commit and push
139128
run: |
140-
ls -R bioconda-recipes/recipes/${PACKAGE}
141-
cat bioconda-recipes/config.yml
142-
143-
# - name: Commit and push
144-
# run: |
145-
# cd bioconda-recipes
146-
# git add recipes/${PACKAGE}
147-
# git commit -m "Update ${PACKAGE} recipe to v$VERSION"
148-
# git push origin add-${PACKAGE}-${VERSION}
149-
150-
# - name: Create Pull Request
151-
# uses: peter-evans/create-pull-request@v5
152-
# with:
153-
# token: ${{ secrets.GH_PAT }}
154-
# title: "Update ${PACKAGE} recipe to v${{ env.VERSION }}"
155-
# commit-message: "Auto PR for Bioconda: ${PACKAGE} v${{ env.VERSION }}"
156-
# base: master
157-
# branch: add-${PACKAGE}-${{ env.VERSION }}
158-
# body: |
159-
# This PR was automatically generated by GitHub Actions.
160-
# - Package: ${{ env.PACKAGE }}
161-
# - Version: v${{ env.VERSION }}
162-
# - sha256: ${{ env.SHA256 }}
129+
cd bioconda-recipes
130+
git config user.name "github-actions"
131+
git config user.email "[email protected]"
132+
git add recipes/${PACKAGE}
133+
git commit -m "Add ${PACKAGE} v${VERSION} [auto-generated]"
134+
git push origin add-${PACKAGE}-${VERSION}
135+
136+
- name: Create Pull Request
137+
uses: peter-evans/create-pull-request@v5
138+
with:
139+
token: ${{ secrets.GH_PAT }}
140+
title: "Add ${PACKAGE} recipe v${{ env.VERSION }}"
141+
commit-message: "Auto PR: ${PACKAGE} v${{ env.VERSION }}"
142+
base: master
143+
branch: add-${PACKAGE}-${{ env.VERSION }}
144+
body: |
145+
This PR was automatically generated by GitHub Actions.
146+
- **Package**: ${{ env.PACKAGE }}
147+
- **Version**: v${{ env.VERSION }}
148+
- **SHA256**: ${{ env.SHA256 }}

0 commit comments

Comments
 (0)