-
Notifications
You must be signed in to change notification settings - Fork 5
91 lines (88 loc) · 3.15 KB
/
python-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Publish to PyPI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry install
pip install toml
- name: Check if trying to bump main package
id: check_version
run: |
PACKAGE_VERSION=$(poetry version --short)
RESPONSE=$(curl -s --head https://pypi.org/pypi/langevals/$PACKAGE_VERSION/json)
if [[ $RESPONSE == *"HTTP/2 200"* ]]; then
echo "NEW_VERSION=false" >> $GITHUB_ENV
else
echo "NEW_VERSION=true" >> $GITHUB_ENV
fi
- name: Publish core package
run: |
cd langevals_core
PACKAGE_VERSION=$(poetry version --short)
RESPONSE=$(curl -s --head https://pypi.org/pypi/langevals_core/$PACKAGE_VERSION/json)
if [[ $RESPONSE == *"HTTP/2 200"* ]]; then
# if new version
if [ "${{ env.NEW_VERSION }}" == "true" ]; then
../scripts/check_version_bump.sh
fi
echo "langevals_core version already exists, skipping publish"
else
echo "Publishing langevals_core"
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
fi
cd ..
- name: Publish evaluator subpackages
run: |
for dir in evaluators/*; do
if [ -d "$dir" ]; then
cd $dir
PACKAGE_VERSION=$(poetry version --short)
DIR_NAME=$(basename $dir)
RESPONSE=$(curl -s --head https://pypi.org/pypi/langevals_$DIR_NAME/$PACKAGE_VERSION/json)
if [[ $RESPONSE == *"HTTP/2 200"* ]]; then
if [ "${{ env.NEW_VERSION }}" == "true" ]; then
python ../../scripts/replace_develop_dependencies.py pyproject.toml
../../scripts/check_version_bump.sh
fi
echo "$dir version already exists, skipping publish"
else
echo "Publishing $dir"
python ../../scripts/replace_develop_dependencies.py pyproject.toml
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
fi
cd ../..
fi
done
- name: Publish main package
run: |
if [ "${{ env.NEW_VERSION }}" == "false" ]; then
echo "langevals version already exists, skipping publish"
else
echo "Publishing langevals"
python scripts/replace_develop_dependencies.py pyproject.toml
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
fi