Skip to content

Commit 9a9ea67

Browse files
authored
Merge pull request #2 from AgentX-ai/robin/fix
fix version
2 parents c6c682a + b38d6d4 commit 9a9ea67

File tree

1 file changed

+26
-102
lines changed

1 file changed

+26
-102
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ jobs:
3333
python -m pip install --upgrade pip
3434
pip install build twine wheel packaging
3535
36-
- name: Get current version
37-
id: current_version
38-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
39-
run: |
40-
python -c "
41-
import re
42-
with open('agentx/version.py', 'r') as f:
43-
content = f.read()
44-
current_version = re.search(r'VERSION = \"([^\"]+)\"', content).group(1)
45-
print(f'current_version={current_version}')
46-
" >> $GITHUB_OUTPUT
47-
4836
- name: Bump version (only on main branch pushes)
4937
id: bump
5038
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
@@ -61,115 +49,51 @@ jobs:
6149
with open('agentx/version.py', 'w') as f:
6250
f.write(new_content)
6351
print(f'Bumped version from {current_version} to {new_version}')
52+
"
53+
54+
- name: Get new version
55+
id: version
56+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
57+
run: |
58+
python -c "
59+
import re
60+
with open('agentx/version.py', 'r') as f:
61+
content = f.read()
62+
new_version = re.search(r'VERSION = \"([^\"]+)\"', content).group(1)
6463
print(f'new_version={new_version}')
65-
" | tee /tmp/version_output.txt
66-
grep 'new_version=' /tmp/version_output.txt >> $GITHUB_OUTPUT
64+
" >> $GITHUB_OUTPUT
6765
68-
- name: Commit and push version bump
66+
- name: Commit version bump
6967
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
7068
run: |
7169
git config --local user.email "github-actions[bot]@users.noreply.github.com"
7270
git config --local user.name "github-actions[bot]"
7371
git add agentx/version.py
74-
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }} [skip ci]"
75-
git push origin main
72+
git commit -m "Bump version to ${{ steps.version.outputs.new_version }} [skip ci]"
73+
git push
7674
77-
- name: Wait for version bump to be available
75+
- name: Wait for version bump commit and fetch latest
7876
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
7977
run: |
80-
echo "Waiting for version bump commit to be available..."
81-
sleep 30 # Increased wait time to ensure GitHub processes the push
82-
83-
# Verify the version bump was successful by checking out fresh
78+
sleep 15 # Wait for the version bump commit to be processed
8479
git fetch origin main
8580
git checkout main
8681
git pull origin main
8782
88-
# Verify the version was actually bumped
89-
python -c "
90-
import re
91-
with open('agentx/version.py', 'r') as f:
92-
content = f.read()
93-
actual_version = re.search(r'VERSION = \"([^\"]+)\"', content).group(1)
94-
expected_version = '${{ steps.bump.outputs.new_version }}'
95-
if actual_version != expected_version:
96-
print(f'ERROR: Version mismatch! Expected {expected_version}, got {actual_version}')
97-
exit(1)
98-
print(f'Version verification successful: {actual_version}')
99-
"
100-
101-
- name: Verify setup.py version
102-
run: |
103-
python -c "
104-
import sys
105-
sys.path.insert(0, '.')
106-
from setup import get_version
107-
version = get_version()
108-
print(f'setup.py get_version() returns: {version}')
109-
"
110-
111-
- name: Build package
83+
- name: Verify version for PyPI
84+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
11285
run: |
113-
# Clean any previous builds
114-
rm -rf dist/ build/ *.egg-info/
115-
116-
# Double-check we're using the correct version before building
11786
python -c "
11887
import re
11988
with open('agentx/version.py', 'r') as f:
12089
content = f.read()
12190
version = re.search(r'VERSION = \"([^\"]+)\"', content).group(1)
122-
print(f'Building package with version: {version}')
91+
print(f'Version to be published to PyPI: {version}')
12392
"
12493
125-
python -m build
126-
127-
- name: Verify built package version
94+
- name: Build package
12895
run: |
129-
# Verify the built package has the correct version
130-
python -c "
131-
import tarfile
132-
import os
133-
import re
134-
135-
# Find the built package
136-
dist_files = [f for f in os.listdir('dist') if f.endswith('.tar.gz')]
137-
if not dist_files:
138-
print('ERROR: No tar.gz package found in dist/')
139-
exit(1)
140-
141-
package_file = dist_files[0]
142-
print(f'Checking package: {package_file}')
143-
144-
# Extract and check version
145-
with tarfile.open(f'dist/{package_file}', 'r:gz') as tar:
146-
# Find the PKG-INFO file
147-
pkg_info_files = [f for f in tar.getnames() if f.endswith('PKG-INFO')]
148-
if pkg_info_files:
149-
pkg_info = tar.extractfile(pkg_info_files[0])
150-
content = pkg_info.read().decode('utf-8')
151-
print(f'PKG-INFO content:\\n{content}')
152-
version_match = re.search(r'Version: (.+)', content)
153-
if version_match:
154-
package_version = version_match.group(1)
155-
print(f'Package version: {package_version}')
156-
157-
# Compare with expected version
158-
with open('agentx/version.py', 'r') as f:
159-
version_content = f.read()
160-
expected_version = re.search(r'VERSION = \"([^\"]+)\"', version_content).group(1)
161-
162-
if package_version != expected_version:
163-
print(f'ERROR: Package version mismatch! Expected {expected_version}, got {package_version}')
164-
exit(1)
165-
print('Package version verification successful!')
166-
else:
167-
print('ERROR: Could not find version in PKG-INFO')
168-
exit(1)
169-
else:
170-
print('ERROR: No PKG-INFO file found in package')
171-
exit(1)
172-
"
96+
python -m build
17397
17498
- name: Publish to PyPI
17599
env:
@@ -184,13 +108,13 @@ jobs:
184108
env:
185109
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186110
with:
187-
tag_name: v${{ steps.bump.outputs.new_version }}
188-
release_name: Release v${{ steps.bump.outputs.new_version }}
111+
tag_name: v${{ steps.version.outputs.new_version }}
112+
release_name: Release v${{ steps.version.outputs.new_version }}
189113
body: |
190-
Automated release for version ${{ steps.bump.outputs.new_version }}
114+
Automated release for version ${{ steps.version.outputs.new_version }}
191115
192116
Changes in this release:
193-
- Automated version bump from ${{ steps.current_version.outputs.current_version }} to ${{ steps.bump.outputs.new_version }}
117+
- Automated version bump
194118
- PyPI package update
195119
draft: false
196120
prerelease: false

0 commit comments

Comments
 (0)