Skip to content

Commit 626cc5e

Browse files
authored
chore(publish): anaconda (#84)
Description Publishing Utils package to Anaconda repository. Links ENSC-856
1 parent 20f49c8 commit 626cc5e

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ jobs:
99
name: Deploy to package index
1010
runs-on: ubuntu-20.04
1111
env:
12+
PYTHON_VERSION: 3.9
1213
REPOSITORY_USERNAME: ${{ secrets.PYPI_USERNAME }}
1314
REPOSITORY_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
1415
REPOSITORY_URL: ${{ secrets.PYPI_PUBLISH_URL }}
16+
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
17+
CONDA_ENV_NAME: conda-env
1518

1619
steps:
1720
- name: Checkout repository
@@ -20,7 +23,14 @@ jobs:
2023
- name: Setup Python
2124
uses: actions/setup-python@v5
2225
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 }}
2434

2535
- name: Install Poetry
2636
uses: snok/install-poetry@v1
@@ -37,3 +47,55 @@ jobs:
3747
- name: Publish
3848
run: |
3949
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

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# FactSet SDK Utilities for Python
44

55
[![PyPi](https://img.shields.io/pypi/v/fds.sdk.utils)](https://pypi.org/project/fds.sdk.utils/)
6+
[![Anaconda-Server Badge](https://anaconda.org/factset/fds.sdk.utils/badges/version.svg)](https://anaconda.org/factset/fds.sdk.utils)
67
[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)
78

89
This repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet
@@ -22,6 +23,12 @@ poetry add fds.sdk.utils
2223
pip install fds.sdk.utils
2324
```
2425

26+
### Conda
27+
28+
```sh
29+
conda install factset::fds.sdk.utils
30+
```
31+
2532
## Usage
2633

2734
This library contains multiple modules, sample usage of each module is below.

0 commit comments

Comments
 (0)