-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (64 loc) · 2.02 KB
/
release.yml
File metadata and controls
66 lines (64 loc) · 2.02 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
64
65
66
name: Release and Publish
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
ref: main
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Extract version
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}" # 移除 v 前缀
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "Extracted version: ${VERSION}"
- name: Update pyproject.toml
run: |
sed -i 's/^version = "[^"]*"/version = "'${VERSION}'"/' pyproject.toml
echo "Updated pyproject.toml version to ${VERSION}"
- name: Update __version__ in __init__.py
run: |
if grep -q "__version__" agentrun/__init__.py; then
sed -i 's/__version__ = "[^"]*"/__version__ = "'${VERSION}'"/' agentrun/__init__.py
else
sed -i '1a __version__ = "'${VERSION}'"' agentrun/__init__.py
fi
echo "Updated __init__.py version to ${VERSION}"
- name: Commit changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add pyproject.toml agentrun/__init__.py
if git diff --staged --quiet; then
echo "No version changes to commit"
else
git commit -m "Update version to ${VERSION}"
git push
fi
- name: Build package
run: |
python -m pip install --upgrade pip
pip install build twine
python -m build
echo "Package built successfully"
- name: Verify package
run: |
python -m twine check dist/*
echo "Package verification completed"
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verify-metadata: false