Skip to content

Commit 0ef497e

Browse files
committed
chore(ci): automate releases
1 parent 1ddb54a commit 0ef497e

File tree

4 files changed

+47
-15
lines changed

4 files changed

+47
-15
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 28 * *' # Monthly auto-release
6+
workflow_dispatch: # Manual trigger for quick fixes
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- name: Python Semantic Release
16+
uses: relekang/python-semantic-release@master
17+
with:
18+
github_token: ${{ secrets.GITHUB_TOKEN }}
19+
pypi_token: ${{ secrets.PYPI_TOKEN }}

.gitlab-ci.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,6 @@ stages:
44
- deploy
55
- deploy-latest
66

7-
deploy:
8-
stage: deploy
9-
script:
10-
- pip install -U setuptools wheel twine
11-
- python setup.py sdist bdist_wheel
12-
# test package
13-
- python3 -m venv test
14-
- . test/bin/activate
15-
- pip install -U dist/python_gitlab*.whl
16-
- gitlab -h
17-
- deactivate
18-
- twine upload --skip-existing -u $TWINE_USERNAME -p $TWINE_PASSWORD dist/*
19-
only:
20-
- tags
21-
227
deploy_image:
238
stage: deploy
249
image:

README.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,27 @@ To cleanup the environment delete the container:
213213
docker rm -f gitlab-test
214214
docker rm -f gitlab-runner-test
215215
216+
Releases
217+
--------
218+
219+
A release is automatically published once a month on the 28th if any commits merged
220+
to the main branch contain commit message types that signal a semantic version bump
221+
(``fix``, ``feat``, ``BREAKING CHANGE:``).
222+
223+
Additionally, the release workflow can be run manually by maintainers to publish urgent
224+
fixes, either on GitHub or using the ``gh`` CLI with ``gh workflow run release.yml``.
225+
226+
**Note:** As a maintainer, this means you should carefully review commit messages
227+
used by contributors in their pull requests. If scopes such as ``fix`` and ``feat``
228+
are applied to trivial commits not relevant to end users, it's best to squash their
229+
pull requests and summarize the addition in a single conventional commit.
230+
This avoids triggering incorrect version bumps and releases without functional changes.
231+
232+
The release workflow uses `python-semantic-release
233+
<https://python-semantic-release.readthedocs.io>`_ and does the following:
234+
235+
* Bumps the version in ``__version__.py`` and adds an entry in ``CHANGELOG.md``,
236+
* Commits and tags the changes, then pushes to the main branch as the ``github-actions`` user,
237+
* Creates a release from the tag and adds the changelog entry to the release notes,
238+
* Uploads the package as assets to the GitHub release,
239+
* Uploads the package to PyPI using ``PYPI_TOKEN`` (configured as a secret).

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.semantic_release]
2+
version_variable = "gitlab/__version__.py:__version__"
3+
commit_subject = "chore: release v{version}"
4+
commit_message = ""

0 commit comments

Comments
 (0)