|
9 | 9 | name: Deploy to package index |
10 | 10 | runs-on: ubuntu-20.04 |
11 | 11 | env: |
| 12 | + PYTHON_VERSION: 3.9 |
12 | 13 | REPOSITORY_USERNAME: ${{ secrets.PYPI_USERNAME }} |
13 | 14 | REPOSITORY_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
14 | 15 | REPOSITORY_URL: ${{ secrets.PYPI_PUBLISH_URL }} |
| 16 | + ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} |
| 17 | + CONDA_ENV_NAME: conda-env |
15 | 18 |
|
16 | 19 | steps: |
17 | 20 | - name: Checkout repository |
|
20 | 23 | - name: Setup Python |
21 | 24 | uses: actions/setup-python@v5 |
22 | 25 | with: |
23 | | - python-version: '3.9' |
| 26 | + python-version: ${{ env.PYTHON_VERSION }} |
| 27 | + |
| 28 | + - name: Setup Conda |
| 29 | + uses: conda-incubator/setup-miniconda@v3 |
| 30 | + with: |
| 31 | + miniconda-version: "latest" |
| 32 | + activate-environment: ${{ env.CONDA_ENV_NAME }} |
| 33 | + python-version: ${{ env.PYTHON_VERSION }} |
24 | 34 |
|
25 | 35 | - name: Install Poetry |
26 | 36 | uses: snok/install-poetry@v1 |
|
37 | 47 | - name: Publish |
38 | 48 | run: | |
39 | 49 | poetry publish -r publish |
| 50 | +
|
| 51 | + - name: Publish to Anaconda |
| 52 | + shell: bash -el {0} |
| 53 | + run: | |
| 54 | + conda install grayskull conda-build anaconda-client |
| 55 | + conda info |
| 56 | + conda list |
| 57 | + grayskull --version |
| 58 | + anaconda --version |
| 59 | + |
| 60 | + count=0 |
| 61 | + max_retries=5 |
| 62 | + tag=${{ github.event.release.tag_name }} |
| 63 | + version=${tag#v} |
| 64 | + while [ $count -lt $max_retries ]; do |
| 65 | + # Create meta.yaml recipe for the package pulled from PyPi |
| 66 | + grayskull pypi fds.sdk.utils==${version} |
| 67 | + |
| 68 | + if [ -f ./fds.sdk.utils/meta.yaml ]; then |
| 69 | + echo "Version ${version} of fds.sdk.utils is available on PyPI." |
| 70 | +
|
| 71 | + # Modify the meta.yaml recipe-maintainers property to include all maintainers of this repo |
| 72 | + sed -i "/recipe-maintainers:/,/extra:/ s/- .*/- gdulafactset/" fds.sdk.utils/meta.yaml |
| 73 | + echo " - mima0815" >> fds.sdk.utils/meta.yaml |
| 74 | + echo " - eschmidtfds" >> fds.sdk.utils/meta.yaml |
| 75 | + echo " - Filip1x9" >> fds.sdk.utils/meta.yaml |
| 76 | + echo " - dgawande12" >> fds.sdk.utils/meta.yaml |
| 77 | +
|
| 78 | + # Modify meta.yaml to include description and dev_url |
| 79 | + sed -i "/about:/a \\ |
| 80 | + dev_url: \"https://github.com/factset/enterprise-sdk-utils-python\"\\ |
| 81 | + description: \"This repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet APIs.\" |
| 82 | + " "fds.sdk.utils/meta.yaml" |
| 83 | +
|
| 84 | + # Build conda package |
| 85 | + conda config --set anaconda_upload no |
| 86 | + package_file=$(conda build fds.sdk.utils --output) |
| 87 | + conda build -c conda-forge fds.sdk.utils |
| 88 | + |
| 89 | + anaconda -t $ANACONDA_TOKEN upload -u factset -l main ${package_file} |
| 90 | + break |
| 91 | + else |
| 92 | + echo "Version ${version} not found, rechecking in $((2 ** count)) seconds..." |
| 93 | + sleep $((2 ** count)) |
| 94 | + count=$((count + 1)) |
| 95 | + fi |
| 96 | + done |
| 97 | +
|
| 98 | + if [ $count -eq $max_retries ]; then |
| 99 | + echo "Maximum retries reached, package with that version was not found, publish failed." |
| 100 | + exit 1 |
| 101 | + fi |
0 commit comments