Skip to content

Commit

Permalink
Add versioning (#26)
Browse files Browse the repository at this point in the history
* Institute major, minor, patch releases - no rc yet

* Add release candidates

* Improve docs, add more automation

* Appease the linter

* Fix headers
  • Loading branch information
JonZeolla authored Jun 15, 2021
1 parent d25043c commit b2e4ce1
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 9 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: "Prerelease"

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'

jobs:
distribute:
name: Distribute
runs-on: Ubuntu-20.04
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Setup the dependencies
run: |
python -m pip install --upgrade pipenv
pipenv install --dev
- name: Publish the release to GitHub
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref }} release
draft: false
prerelease: true
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: "Release"

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
distribute:
name: Distribute
runs-on: Ubuntu-20.04
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Setup the dependencies
run: |
python -m pip install --upgrade pipenv
pipenv install --dev
- name: Publish the release to GitHub
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref }} release
draft: false
prerelease: false
33 changes: 33 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Copyright 2020-2021 Zeek-Kafka
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
# Maintainers Guide

This guide is intended for maintainers — anybody with commit access to the `zeek-kafka` repository.

## Releases

All `zeek-kafka` releases first have a release candidate prior to being promoted to general availability.

In order to create a release, you must have `pipenv` and `python3` installed, and then run the following commands, where `$TYPE` is one of `major`, `minor`, `patch`, `build`, or `release`.

```bash
TYPE=major
REMOTE=origin

git checkout main # Releases should always come from main
pipenv run invoke version $TYPE
git push --atomic $REMOTE $(git branch --show-current) $(git tag --points-at HEAD)
```

The previous commands result in a tagged commit containing updated version references in `zkg.meta` and `README.md` (as defined in `setup.cfg`) being pushed to GitHub, at which point GitHub actions performs the remaining release actions based on `.github/workflows/release.yml` and `.github/workflows/prerelease.yml`.
14 changes: 14 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]
bumpversion = "*"
gitpython = "*"
invoke = "*"

[requires]
python_version = "3.9"
70 changes: 70 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ A Zeek log writer that sends logging output to Kafka, providing a convenient mea
1. Install the plugin using `zkg install`.

```
$ zkg install seisollc/zeek-kafka --version main
$ zkg install seisollc/zeek-kafka --version 0.4.0
The following packages will be INSTALLED:
zeek/seisollc/zeek-kafka (main)
zeek/seisollc/zeek-kafka (0.4.0)
Verify the following REQUIRED external dependencies:
(Ensure their installation on all relevant systems before proceeding):
from zeek/seisollc/zeek-kafka (main):
from zeek/seisollc/zeek-kafka (0.4.0):
librdkafka ~1.4.2
Proceed? [Y/n]
Expand All @@ -62,15 +62,15 @@ A Zeek log writer that sends logging output to Kafka, providing a convenient mea
Installing "zeek/seisollc/zeek-kafka"........
Installed "zeek/seisollc/zeek-kafka" (main)
Installed "zeek/seisollc/zeek-kafka" (0.4.0)
Loaded "zeek/seisollc/zeek-kafka"
```

1. Run the following command to ensure that the plugin was installed successfully.

```
$ zeek -N Seiso::Kafka
Seiso::Kafka - Writes logs to Kafka (dynamic, version 0.3.0)
Seiso::Kafka - Writes logs to Kafka (dynamic, version 0.4.0)
```

### Manual Installation
Expand Down Expand Up @@ -104,7 +104,7 @@ These instructions could also be helpful if you were interested in distributing

```
$ zeek -N Seiso::Kafka
Seiso::Kafka - Writes logs to Kafka (dynamic, version 0.3.0)
Seiso::Kafka - Writes logs to Kafka (dynamic, version 0.4.0)
```

## Activation
Expand Down
6 changes: 4 additions & 2 deletions ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ MISSING_COPYRIGHT=$(find "${DIR}" \( -path "${DIR}/.git" -or \
-and -not -name "*.yml" \
-and -not -name "*.pcap" \
-and -not -name "*.pcapng" \
-and -not -name "requirements*.txt" \
-and -not -name "COPYING" \
-and -not -name "Dockerfile" \
-and -not -name "Pipfile*" \
-and -not -name "output" \
-and -not -name "random.seed" \
-and -not -name "COPYING" \
-and -not -name "requirements*.txt" \
-and -not -name "setup.cfg" \
-and -not -name "zkg.meta" \
-type f \
\) \
Expand Down
24 changes: 24 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[bumpversion]
current_version = 0.4.0
commit_message = "Automatically generated release {new_version}"
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{build}
{major}.{minor}.{patch}
commit = True
tag = True
push = True

[bumpversion:part:release]
optional_value = ga
first_value = rc
values =
rc
ga

[bumpversion:part:build]
first_value = 1

[bumpversion:file:README.md]

[bumpversion:file:zkg.meta]
62 changes: 62 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""
Task execution tool & library
"""

#
# Copyright 2020-2021 Zeek-Kafka
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re
import sys
from logging import basicConfig, getLogger
from pathlib import Path

import json
import git
from bumpversion.cli import main as bumpversion
from invoke import task

LOG_FORMAT = json.dumps(
{
"timestamp": "%(asctime)s",
"namespace": "%(name)s",
"loglevel": "%(levelname)s",
"message": "%(message)s",
}
)

basicConfig(level="INFO", format=LOG_FORMAT)
LOG = getLogger("zeek-kafka.invoke")

CWD = Path(".").absolute()
try:
REPO = git.Repo(CWD)
except git.InvalidGitRepositoryError:
REPO = None


@task
def version(_c, version_type):
"""Make a new release of zeek-kafka"""
if REPO.head.is_detached:
LOG.error("In detached HEAD state, refusing to release")
sys.exit(1)

if version_type not in ["major", "minor", "patch", "build", "release"]:
LOG.error("Please provide a release type of major, minor, patch, build, or release")
sys.exit(1)

bumpversion([version_type])
2 changes: 1 addition & 1 deletion zkg.meta
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ script_dir = build/scripts/Seiso/Kafka
build_command = ./configure --with-librdkafka=%(LIBRDKAFKA_ROOT)s && make
test_command = cd tests && btest -d
plugin_dir = build
version = main
version = 0.4.0
depends =
zeek >=4.0.0
zkg >=2.0
Expand Down

0 comments on commit b2e4ce1

Please sign in to comment.