Repository navigation
63 lines (53 loc) · 1.86 KB
/
Copy pathpython-cli-publish.yml
File metadata and controls
63 lines (53 loc) · 1.86 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
61
62
63
name: Python CLI Publish
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: read
jobs:
publish-python-cli:
runs-on: ubuntu-24.04
environment: pypi
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
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@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
with:
packages-dir: cmd/cli/dist/