Skip to content

Commit

Permalink
Prepare release, use poetry for publishing packages (#23)
Browse files Browse the repository at this point in the history
* Prepare release, use poetry for publishing packages

* Update github actions to latest versions

* Remove publish steps from Makefile, fix prep step

* Fix publish to devpi

* Fetch master explicitly

* Remove obsolete command
  • Loading branch information
Crandel authored Apr 29, 2021
1 parent 98bf439 commit 2063086
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 46 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### How to create a new release

Please follow these steps to create a new `pyconnect` release:

##### 1. Checkout branch `release-prep`
```shell script
git checkout release-prep
# or
git checkout -b release-prep
```
##### 2. Merge the current `master` branch into it (NOTE: the code changes are already merged into the `master` branch at this point)
```shell script
git checkout master
git pull
git checkout release-prep
git merge master
```
##### 3. Run `poetry version` with the appropriate argument (`major`, `minor`, `patch`) to bump the current version
```shell script
poetry version minor
```
##### 4. Update the `CHANGELOG.md` file
##### 5. Commit the changes
```shell script
VERSION="$(sed -n -E "s/^version = \"(.+)\"/\1/p" pyproject.toml)"
git add .
git commit -m "Version changed to v${VERSION}"
```
##### 6. Push the changes
```shell script
git push
```
##### 7. Open pull request to `master` on `https://github.com/real-digital/pyconnect`
##### 8. Once the pull request is merged, create and publish a release. This should trigger a `publish` event that will, in turn, trigger publishing the package to `pypi`
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish esque
on:
release:
types:
- published

jobs:
publish-to-pypi:
name: Publish to pypi
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Setup python and install packages
uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: x64
- name: Publish to pypi
if: success()
run: |
pip install "poetry>=1.0.2"
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry build
poetry publish
31 changes: 0 additions & 31 deletions .github/workflows/pythonpublish.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/release-prep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Verify release
on:
push:
branches:
- release-prep

jobs:
check-version-change:
name: Check version change
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Setup python and install packages
uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: x64
- name: Check version change
run: |
git fetch origin master:master
MASTER_VERSION="$(git show master:pyproject.toml | sed -n -E "s/^version = \"(.+)\"/\1/p")"
echo "Version on master: ${MASTER_VERSION}"
NEW_VERSION="$(sed -n -E "s/^version = \"(.+)\"/\1/p" pyproject.toml)"
echo "Version on release-prep: ${NEW_VERSION}"
(if [[ "${MASTER_VERSION}" == "${NEW_VERSION}" ]]; then
echo 'Need to bump version, please run `poetry version <major|minor|patch|whatever..>`'
exit 1
fi)
publish-to-devpi:
name: Publish to devpi
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Setup python and install packages
uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: x64
- name: Prepare environment for test publish
if: success()
run: |
pip install "poetry>=1.0.2" devpi-server devpi "pluggy<1,>=0.12.0"
devpi-server --serverdir=/tmp/devpi --init
devpi-server --serverdir=/tmp/devpi --start
scripts/wait-for-it.sh localhost:3141 -t 60
devpi use http://localhost:3141
devpi login root --password=
devpi index -c root/stable bases=root/pypi volatile=True
devpi user -m root password="root"
mkdir -p ${HOME}/.esque
poetry config repositories.devpi http://localhost:3141/root/stable/
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Publish to devpi
if: success()
run: |
poetry build
poetry publish --repository devpi --username root --password root
- name: Test devpi release
if: success()
run: |
VERSION=$(sed -n -E "s/^version = \"(.+)\"/\1/p" pyproject.toml)
pushd /tmp
pip install setuptools
pip install -i http://localhost:3141/root/stable/ --timeout 60 pyconnect
CURRENT_VERSION=$(python -c 'import pkg_resources;print(pkg_resources.get_distribution("pyconnect").version)')
[[ ${CURRENT_VERSION} == ${VERSION} ]]
popd
- name: Publish to testpypi
if: success()
run: |
VERSION=$(sed -n -E "s/^version = \"(.+)\"/\1/p" pyproject.toml)
git fetch origin master:master
BUILD=$(git rev-list --count HEAD...master)
sed -i -E "s/^version = .*/version = \"${VERSION}.dev${BUILD}\"/" pyproject.toml
poetry build
poetry publish --repository testpypi
8 changes: 4 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
python: ['3.8']
os: ['ubuntu-latest']
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand All @@ -35,15 +35,15 @@ jobs:
matrix:
python: ['3.6', '3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Fetch virtualenv cache
uses: actions/cache@v1
id: venv-cache
with:
path: .venv
key: venv-${{ matrix.python }}-${{ hashFiles('poetry.lock') }}
- name: Setup python and install packages
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### Version 0.5.1
* use poetry to publish packages
### Version 0.5.0
#### Breaking changes
* update confluent-kafka-python to version 1.6.1
* Use DeserializingConsumer instead of deprecated AvroConsumer and SerializingProducer instead of AvroProducer
* remove RichAvroConsumer
#### Other changes
* replace pipenv with poetry
* use docker-compose for tests
### Version 0.4.5
* Enabled the Sink to retry committing offsets in case of failure. The maximum number of retries is configurable through
the `sink_commit_retry_count` field.
Expand All @@ -6,6 +16,6 @@ the `sink_commit_retry_count` field.
### Version 0.4.3
* Fix bug fix introduced in Version 0.4.2, only commit offsets if exist.
### Version 0.4.2
* Make consumer offset commits synchronous.
* Make consumer offset commits synchronous.
### Version 0.4.1
* Introduce hashing of sensitive values.
* Introduce hashing of sensitive values.
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ consume-%: boot-cluster

list-topics: boot-cluster
kafkacat -b broker:9092 -L

publish-test:
rm -rf dist
python setup.py sdist bdist_wheel
twine upload dist/* --repository-url https://test.pypi.org/legacy/

publish: publish-test
poetry publish
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyconnect"
version = "0.5.0"
version = "0.5.1"
description='A Python implementation of "Kafka Connect"-like functionality'
authors = ["real.digital <opensource@real-digital.de>"]
exclude = ["tests/**/*"]
Expand Down

0 comments on commit 2063086

Please sign in to comment.