@@ -17,10 +17,10 @@ jobs:
1717 name : pypi-universalpython
1818
1919 steps :
20- - name : Checkout repository
21- uses : actions/checkout@v4
20+ - uses : actions/checkout@v4
2221 with :
2322 fetch-depth : 0
23+ token : ${{ secrets.GITHUB_TOKEN }}
2424
2525 - name : Set up Python
2626 uses : actions/setup-python@v5
@@ -33,34 +33,66 @@ jobs:
3333 pip install build twine python-semantic-release
3434 pip install -r utils/requirements.txt
3535
36- - name : Bump version using semantic-release
37- id : semantic
38- env :
39- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36+ - name : Configure Git
4037 run : |
41- echo "🚀 Running semantic-release... "
42- semantic-release version --commit --tag --push || echo "No version bump "
38+ git config user.name "github-actions[bot] "
39+ git config user.email "github-actions[bot]@users.noreply.github.com "
4340
44- - name : Check updated version
45- id : version_check
41+ - name : Run semantic release
42+ id : release
43+ env :
44+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4645 run : |
47- VERSION=$(grep -E '^version\s*=' pyproject.toml | head -n 1 | sed -E 's/version\s*=\s*"(.*)"/\1/')
48- echo "version=$VERSION" >> $GITHUB_OUTPUT
49- echo "📦 Detected version: $VERSION"
46+ set +e
47+ python -m semantic_release version --no-push
48+ RELEASE_EXIT_CODE=$?
49+ set -e
50+
51+ if [ $RELEASE_EXIT_CODE -eq 0 ]; then
52+ echo "version_created=true" >> $GITHUB_OUTPUT
53+ # Get the new version
54+ NEW_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
55+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
56+ echo "New version: $NEW_VERSION"
57+
58+ # Push changes
59+ git push origin release --tags
60+ else
61+ echo "version_created=false" >> $GITHUB_OUTPUT
62+ echo "No new version created (exit code: $RELEASE_EXIT_CODE)"
63+ fi
5064
5165 - name : Build package
66+ if : steps.release.outputs.version_created == 'true'
67+ run : bash utils/build_package.sh
68+
69+ - name : Check distribution files
70+ if : steps.release.outputs.version_created == 'true'
5271 run : |
53- echo "🛠️ Building package..."
54- bash utils/build_package.sh
55- echo "✅ Build complete"
56- ls -l dist/
72+ ls -lah dist/
73+ echo "Files to be uploaded:"
74+ find dist/ -type f
5775
5876 - name : Publish to PyPI
59- if : success()
77+ if : steps.release.outputs.version_created == 'true'
6078 uses : pypa/gh-action-pypi-publish@release/v1
6179 with :
6280 packages-dir : dist/
63-
64- - name : Confirm release complete
81+ skip-existing : true
82+ verbose : true
83+
84+ - name : Summary
85+ if : steps.release.outputs.version_created == 'true'
86+ run : |
87+ echo "## 🚀 Release Published" >> $GITHUB_STEP_SUMMARY
88+ echo "Version: ${{ steps.release.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
89+ echo "Package: https://pypi.org/project/universalpython/${{ steps.release.outputs.new_version }}/" >> $GITHUB_STEP_SUMMARY
90+
91+ - name : No release needed
92+ if : steps.release.outputs.version_created != 'true'
6593 run : |
66- echo "🎉 PyPI release complete for version: ${{ steps.version_check.outputs.version }}"
94+ echo "## ℹ️ No Release Created" >> $GITHUB_STEP_SUMMARY
95+ echo "No new version was created. Make sure you have commits following conventional commit format:" >> $GITHUB_STEP_SUMMARY
96+ echo "- \`feat:\` for new features (minor version bump)" >> $GITHUB_STEP_SUMMARY
97+ echo "- \`fix:\` for bug fixes (patch version bump)" >> $GITHUB_STEP_SUMMARY
98+ echo "- \`BREAKING CHANGE:\` in commit body for major version bump" >> $GITHUB_STEP_SUMMARY
0 commit comments