forked from volcano-sh/agentcube
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 1.7 KB
/
python-cli-publish.yml
File metadata and controls
60 lines (51 loc) · 1.7 KB
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
name: Python CLI Publish
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
publish-python-cli:
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build dependency
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: make build-python-cli
- name: Read package version
id: package
working-directory: cmd/cli
run: |
version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Check whether version already exists on PyPI
id: pypi
env:
PACKAGE_NAME: agentcube-cli
PACKAGE_VERSION: ${{ steps.package.outputs.version }}
run: |
status="$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/${PACKAGE_NAME}/${PACKAGE_VERSION}/json")"
if [ "$status" = "200" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Version ${PACKAGE_VERSION} already exists on PyPI, skipping publish."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Version ${PACKAGE_VERSION} is not published yet."
fi
- name: Publish package to PyPI
if: steps.pypi.outputs.exists != 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: cmd/cli/dist/