Skip to content

Commit 9643c47

Browse files
author
Sergio Soto
authored
feat: adds github workflow for publishing to pypi (#7)
* feat: adds github workflow for publishing to pypi * fix: adds cz and use in workflow * doc: updates CHANGELOG.md
1 parent a2c53bc commit 9643c47

File tree

4 files changed

+200
-4
lines changed

4 files changed

+200
-4
lines changed

.github/workflows/publish.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
publish_to_pypi:
9+
description: 'Publish to PyPI'
10+
required: true
11+
default: false
12+
type: boolean
13+
14+
jobs:
15+
build:
16+
name: Build distribution
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: "3.x"
26+
27+
- name: Install build dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install build
31+
32+
- name: Build package
33+
run: python -m build
34+
35+
- name: Upload distribution artifacts
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: python-package-distributions
39+
path: dist/
40+
41+
publish-to-pypi:
42+
name: Publish to PyPI
43+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_pypi == 'true')
44+
needs: build
45+
runs-on: ubuntu-latest
46+
47+
permissions:
48+
id-token: write # IMPORTANT: mandatory for trusted publishing
49+
50+
steps:
51+
- name: Download distribution artifacts
52+
uses: actions/download-artifact@v3
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
- name: Publish distribution to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1
59+
60+
publish-to-testpypi:
61+
name: Publish to TestPyPI
62+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_pypi == 'false'
63+
needs: build
64+
runs-on: ubuntu-latest
65+
66+
permissions:
67+
id-token: write # IMPORTANT: mandatory for trusted publishing
68+
69+
steps:
70+
- name: Download distribution artifacts
71+
uses: actions/download-artifact@v3
72+
with:
73+
name: python-package-distributions
74+
path: dist/
75+
76+
- name: Publish distribution to TestPyPI
77+
uses: pypa/gh-action-pypi-publish@release/v1
78+
with:
79+
repository-url: https://test.pypi.org/legacy/

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
release:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.x"
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install commitizen
32+
33+
- name: Configure Git
34+
run: |
35+
git config --global user.name "github-actions[bot]"
36+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
37+
38+
- name: Check for changes to release
39+
id: check_changes
40+
run: |
41+
if cz check --rev-range HEAD~1..HEAD; then
42+
echo "has_changes=true" >> $GITHUB_OUTPUT
43+
else
44+
echo "has_changes=false" >> $GITHUB_OUTPUT
45+
fi
46+
continue-on-error: true
47+
48+
- name: Bump version and create changelog
49+
if: steps.check_changes.outputs.has_changes == 'true'
50+
run: |
51+
cz bump --yes --changelog
52+
53+
- name: Push changes
54+
if: steps.check_changes.outputs.has_changes == 'true'
55+
run: |
56+
git push
57+
git push --tags
58+
59+
- name: Get version
60+
if: steps.check_changes.outputs.has_changes == 'true'
61+
id: get_version
62+
run: |
63+
echo "version=$(cz version --project)" >> $GITHUB_OUTPUT
64+
65+
- name: Create GitHub Release
66+
if: steps.check_changes.outputs.has_changes == 'true'
67+
uses: actions/create-release@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
tag_name: v${{ steps.get_version.outputs.version }}
72+
release_name: Release v${{ steps.get_version.outputs.version }}
73+
body_path: CHANGELOG.md
74+
draft: false
75+
prerelease: false

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Initial syllabification module for Spanish words
12+
- GitHub Actions workflow for automated PyPI publishing
13+
- Commitizen integration for automated versioning and changelog generation
14+
15+
## [0.0.1] - 2025-06-24
16+
17+
### Added
18+
- Initial release of epa_syllabicate module
19+
- Basic syllabification functionality
20+
- Test suite with pytest
21+
- Project configuration with pyproject.toml

pyproject.toml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,53 @@ build-backend = "hatchling.build"
55
[project]
66
name = "epa_syllabicate"
77
version = "0.1.0"
8-
description = "Módulo para silabificación de palabras"
8+
description = "Automatic syllabification module for Spanish words"
99
readme = "README.md"
1010
requires-python = ">=3.8"
1111
license = "MIT"
1212
authors = [
1313
{ name = "EPA Team" }
1414
]
15+
keywords = ["syllabification", "spanish", "nlp", "text-processing", "linguistics"]
1516
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Intended Audience :: Developers",
19+
"Intended Audience :: Science/Research",
20+
"Topic :: Text Processing :: Linguistic",
21+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
1622
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
1728
"License :: OSI Approved :: MIT License",
1829
"Operating System :: OS Independent",
1930
]
2031
dependencies = []
2132

2233
[project.urls]
23-
"Homepage" = ""
24-
"Bug Tracker" = ""
34+
"Homepage" = "https://github.com/andalugeeks/epa-syllabicate"
35+
"Bug Tracker" = "https://github.com/andalugeeks/epa-syllabicate/issues"
36+
"Repository" = "https://github.com/andalugeeks/epa-syllabicate.git"
2537

2638
[project.optional-dependencies]
2739
dev = [
2840
"pytest>=7.0.0",
2941
"pytest-cov>=4.0.0",
3042
"ipdb",
3143
"black",
44+
"commitizen>=3.0.0",
3245
]
3346

3447
[tool.pytest.ini_options]
3548
testpaths = ["tests"]
36-
python_files = ["test_*.py"]
49+
python_files = ["test_*.py"]
50+
51+
[tool.commitizen]
52+
name = "cz_conventional_commits"
53+
tag_format = "v$version"
54+
version_scheme = "pep440"
55+
version_provider = "pep621"
56+
update_changelog_on_bump = true
57+
major_version_zero = true

0 commit comments

Comments
 (0)