Skip to content

Commit 2323b88

Browse files
committed
feat: major update
1 parent ee8941a commit 2323b88

2 files changed

Lines changed: 59 additions & 24 deletions

File tree

.github/workflows/release-to-pypi.yml

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "universalpython"
7-
version = "0.1.9-b.7"
7+
version = "0.1.9-b7"
88
authors = [
99
{name = "Saad Bazaz", email = "saadbazaz@hotmail.com"},
1010
]
@@ -47,15 +47,18 @@ universalpython = "universalpython.universalpython:main"
4747
[tool.semantic_release]
4848
version_toml = ["pyproject.toml:project.version"]
4949
upload_to_pypi = false
50-
tag_format = "{version}"
50+
tag_format = "v{version}"
5151
build_command = "bash ./utils/build_package.sh"
52-
commit_parser = "conventional"
52+
commit_parser = "angular"
5353
major_on_zero = true
5454
allow_zero_version = true
5555
prerelease_token = "b"
5656
changelog_file = "./CHANGELOG.md"
5757

5858
[tool.semantic_release.commit_parser_options]
59+
allowed_tags = ["feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert"]
60+
minor_tags = ["feat"]
61+
patch_tags = ["fix", "perf"]
5962
parse_squash_commits = true
6063
ignore_merge_commits = true
6164

0 commit comments

Comments
 (0)