-
Notifications
You must be signed in to change notification settings - Fork 7
76 lines (73 loc) · 2.49 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
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
- 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
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)
RESPONSE=$(curl -s --head https://pypi.org/pypi/langevals_$dir/$PACKAGE_VERSION/json)
if [[ $RESPONSE == *"HTTP/2 200"* ]]; then
echo "$dir version already exists, skipping publish"
else
echo "Publishing $dir"
sed -i 's/, develop = true//g' pyproject.toml
rm -rf poetry.lock
poetry lock
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
fi
cd ../..
fi
done
- name: Publish main package
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 "langevals_core version already exists, skipping publish"
else
echo "Publishing langevals"
sed -i 's/develop = true//g' pyproject.toml
poetry lock
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
fi