Skip to content

Commit

Permalink
chore: cd pipeline with semantic release and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Dec 7, 2022
1 parent 1cff78b commit 4b2f012
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:

jobs:
build:
container:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -36,15 +36,14 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
Expand All @@ -56,3 +55,32 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- run: python -m pip install --upgrade pip

- run: pip install -r requirements-dev.txt

- run: make clean

- name: Build Wheel
run: python setup.py sdist bdist_wheel

- name: Run twine
if: github.event_name != 'pull_request'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.RABE_PYPI_TOKEN }}
TWINE_NON_INTERACTIVE: true
run: twine upload dist/*
22 changes: 22 additions & 0 deletions .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run semantic-release

on:
push:
branches:
- main

jobs:
semantic-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run go-semantic-release
id: semrel
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.RABE_ITREAKTION_GITHUB_TOKEN }}
allow-initial-development-versions: true
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,35 @@ As documented in [Usage](#Usage), you can also pass in options on the command li
```bash
./suisa_sendemeldung.py --access_key=abcdefghijklmnopqrstuvwxyzabcdef --stream_id=a-bcdefgh --stdout
```

## Release Management

The CI/CD setup uses semantic commit messages following the [conventional commits standard](https://www.conventionalcommits.org/en/v1.0.0/).
There is a GitHub Action in [.github/workflows/semantic-release.yaml](./.github/workflows/semantic-release.yaml)
that uses [go-semantic-commit](https://go-semantic-release.xyz/) to create new
releases.

The commit message should be structured as follows:

```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```

The commit contains the following structural elements, to communicate intent to the consumers of your library:

1. **fix:** a commit of the type `fix` patches gets released with a PATCH version bump
1. **feat:** a commit of the type `feat` gets released as a MINOR version bump
1. **BREAKING CHANGE:** a commit that has a footer `BREAKING CHANGE:` gets released as a MAJOR version bump
1. types other than `fix:` and `feat:` are allowed and don't trigger a release

If a commit does not contain a conventional commit style message you can fix
it during the squash and merge operation on the PR.

Once a commit has landed on the `main` branch a release will be created and automatically published to [pypi](https://pypi.org/)
using the GitHub Action in [.github/workflows/release.yaml](./.github/workflows/reliease.yaml) which uses [twine](https://twine.readthedocs.io/)
to publish the package to pypi. The `release.yaml` action also takes care of pushing a [container](https://opencontainers.org/)
image to [GitHub Packages](https://github.com/features/packages).

0 comments on commit 4b2f012

Please sign in to comment.