Skip to content

Commit aa8f977

Browse files
Add workflow to publish python sdk
1 parent 9c10eb1 commit aa8f977

File tree

4 files changed

+75
-15
lines changed

4 files changed

+75
-15
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish python sdk
2+
env:
3+
PUBLISHER_IMAGE_TAG: python-sdk-publisher
4+
5+
on:
6+
push:
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
jobs:
12+
publish_pypi:
13+
runs-on: ubuntu-latest
14+
if: startsWith(github.ref, 'refs/tags/v')
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Build python sdk publisher image
18+
run: |
19+
docker build sdks/python-sdk -t $PUBLISHER_IMAGE_TAG
20+
- name: Publish python client
21+
env:
22+
PYPI_USERNAME: agentlabs
23+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24+
VERSION: ${{ github.ref_name }}
25+
run: |
26+
docker run --rm $PUBLISHER_IMAGE_TAG

sdks/python-sdk/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.12.0-alpine3.18
2+
3+
RUN apk add --no-cache \
4+
curl \
5+
toml-adapt \
6+
poetry
7+
8+
ENV PATH="${PATH}:/root/.local/bin"
9+
10+
COPY . .
11+
12+
COPY ./scripts/docker-entrypoint.sh /entrypoint.sh
13+
14+
ENTRYPOINT ["sh", "/entrypoint.sh"]

sdks/python-sdk/build.Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#! /bin/sh
2+
3+
set -e
4+
5+
validate_env() {
6+
if [ -z "$PYPI_USERNAME" ]; then
7+
echo "PYPI_USERNAME env var is not set, exiting"
8+
exit 1
9+
fi
10+
11+
if [ -z "$PYPI_PASSWORD" ]; then
12+
echo "PYPI_PASSWORD env var is not set, exiting"
13+
exit 1
14+
fi
15+
16+
if [ -z "$VERSION" ]; then
17+
echo "VERSION env var is not set, exiting"
18+
exit 1
19+
fi
20+
}
21+
22+
prepare_config() {
23+
sed -i "s/^version = .*$/version = \"$VERSION\"/" pyproject.toml
24+
echo "Wrote version to pyproject.toml ($VERSION)"
25+
}
26+
27+
validate_env
28+
29+
prepare_config
30+
31+
poetry publish --build \
32+
--no-interaction \
33+
--build \
34+
--username "$PYPI_USERNAME" \
35+
--password "$PYPI_PASSWORD"

0 commit comments

Comments
 (0)