Skip to content

Commit 6a96eee

Browse files
chore: automate release process (DSP-1492) (#52)
* chore: add test action * chore: add setup.cfg * chore: add pr-title-check, release-please and release workflow * chore: add PR template * docs: update documentation according to automated release process * fix: correct package name * chore: add notification action * chore: improve PR title Regex * chore: add upper case to PR title regex
1 parent 1176d89 commit 6a96eee

8 files changed

Lines changed: 171 additions & 11 deletions

File tree

‎.github/pull_request_template.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
===REMOVE===
2+
3+
Important! Please follow the new guidelines for naming Pull Requests: https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-guidelines
4+
5+
> **Note:** If a pull request consists consists of *only one* commit when squash-merging it to main, the commit message will *not* be correct. In this case you have to manually ensure that the commit message is identical to the PR title, not the commit that the PR consists of.
6+
7+
===REMOVE===
8+
9+
resolves DSP-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PR-Title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
jobs:
8+
test:
9+
name: Check PR Title
10+
runs-on: ubuntu-latest
11+
steps:
12+
# check PR title
13+
- uses: deepakputhraya/action-pr-title@master
14+
with:
15+
regex: '([a-z])+(\(([a-z\-_])+\))?!?: ([a-zA-Z ])+ \([A-Z]+-\d+\)' # Regex the title should match.
16+
allowed_prefixes: 'fix,refactor,feat,docs,chore,style,test' # title should start with the given prefix
17+
disallowed_prefixes: 'feature,hotfix,doc' # title should not start with the given prefix
18+
prefix_case_sensitive: true # title prefix are case insensitive
19+
min_length: 7 # Min length of the title
20+
max_length: 60 # Max length of the title
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release-Please
2+
3+
# triggered when tests complete on main branch
4+
on:
5+
workflow_run:
6+
workflows:
7+
- "Test"
8+
branches:
9+
- main
10+
types:
11+
- completed
12+
13+
jobs:
14+
refused:
15+
# Refuse if tests failed
16+
runs-on: ubuntu-latest
17+
if: ${{ github.event.workflow_run.conclusion == 'failure'}}
18+
steps:
19+
- id: refused_step
20+
run: exit 1
21+
22+
release-please:
23+
# Automate releases with Conventional Commit Messages as Pull Requests are merged into "main" branch
24+
name: Prepare next release
25+
runs-on: ubuntu-latest
26+
# release only if tests pass
27+
if: ${{ github.event.workflow_run.conclusion == 'success'}}
28+
steps:
29+
- uses: GoogleCloudPlatform/release-please-action@v2
30+
with:
31+
token: ${{ secrets.GH_TOKEN }}
32+
release-type: python
33+
package-name: dsp-tools
34+
changelog-types: '[{"type": "feat", "section": "Enhancements", "hidden": false }, {"type": "fix", "section": "Bug Fixes", "hidden": false }, {"type": "chore", "section": "Maintenance", "hidden": false }, {"type": "refactor", "section": "Maintenance", "hidden": false }, {"type": "docs", "section": "Documentation", "hidden": false }]'

‎.github/workflows/release.yml‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
# set environment variables
8+
env:
9+
TOKEN: ${{ secrets.GH_TOKEN }}
10+
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
11+
TWINE_PASSWORD: ${{ secrets.PYPI_PW }}
12+
13+
jobs:
14+
# release to PyPI
15+
release-pypi:
16+
name: Release to PyPI
17+
runs-on: ubuntu-latest
18+
steps:
19+
# check out repo
20+
- uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 1
23+
# install python
24+
- name: Set up Python
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.9'
28+
# install pythonn dependencies
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -r requirements.txt
33+
# release new version to PyPI
34+
- run: |
35+
make upgrade-dist-tools
36+
make dist
37+
make upload
38+
39+
release-docs:
40+
name: Release Docs
41+
runs-on: ubuntu-latest
42+
steps:
43+
# check out repo
44+
- uses: actions/checkout@v2
45+
with:
46+
fetch-depth: 1
47+
# install python
48+
- name: Set up Python
49+
uses: actions/setup-python@v2
50+
with:
51+
python-version: '3.9'
52+
# install pythonn dependencies
53+
- name: Install dependencies
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install -r requirements.txt
57+
# release latest docs
58+
- run: make publish-docs
59+
60+
notification:
61+
name: Google chat notification about release and published version
62+
needs: [release-pypi, release-docs]
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Send notification to google chat room "DSP releases"
66+
uses: lakto/google-chat-action@main
67+
with:
68+
url: ${{ secrets.GOOGLE_CHAT_DSP_RELEASES_WEBHOOK_URL }}
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
name: CI
1+
name: Test
22

3-
on: [push]
4-
5-
env:
6-
KNORA_GDB_LICENSE: ${{ github.workspace }}/ci/graphdb/UNIBAS_DEV_GRAPHDB_SE_latest-31-12-2020_1cores.license
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened]
77

88
jobs:
99
test-integration:
1010
name: Integration Tests
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
1212
steps:
13+
# run tests
1314
- name: Checkout source
14-
uses: actions/checkout@v1
15+
uses: actions/checkout@v2
1516
with:
1617
fetch-depth: 1
17-
- uses: joschi/setup-jdk@v2
18+
- name: Set up JDK
19+
uses: joschi/setup-jdk@v2
1820
with:
1921
java-version: '11' # The OpenJDK version to make available on the path
2022
architecture: 'x64' # defaults to 'x64'
@@ -30,8 +32,10 @@ jobs:
3032
uses: actions/setup-python@v2
3133
with:
3234
python-version: 3.9
33-
- name: Install python package dependencies
34-
run: sudo apt-get install libxml2-dev libxslt-dev python3-dev libgstreamer1.0-0 gstreamer1.0-plugins-base freeglut3-dev libjpeg-dev libpng-dev libtiff-dev libsdl-dev libnotify-dev libsm-dev
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -r requirements.txt
3539
- name: run test-integration
3640
run: |
3741
make upgrade-dist-tools

‎README.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,18 @@ $ make install
5151
$ make test
5252
```
5353

54-
## Publishing to PyPi
54+
## Publishing
55+
56+
Publishing is automated with github actions and should _not_ be done manually.
57+
58+
Ensure to have only one Pull Request per feature, and follow the [conventions for commit messages and PR title](https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-guidelines).
59+
60+
If this is done correctly, when merging a PR into `main`, the `release-please` action will create or update a release-PR.
61+
This PR will follow semantic versioning and update the change log.
62+
Once all desired features are merged, the release can be executed by merging the release-PR into `main`.
63+
This will trigger actions that create a release on Github, on PyPI and the docs.
64+
65+
### Publishing to PyPi
5566

5667
Generate distribution package. Make sure you have the latest versions of `setuptools` and `wheel` installed.
5768
Remove the `dist`and `buil`-directories: `rm -rf bild dist`

‎docs/index.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ make test
154154

155155
## Publishing
156156

157+
Publishing is automated with github actions and should _not_ be done manually.
158+
159+
Ensure to have only one Pull Request per feature, and follow the [conventions for commit messages and PR title](https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-guidelines).
160+
161+
If this is done correctly, when merging a PR into `main`, the `release-please` action will create or update a release-PR.
162+
This PR will follow semantic versioning and update the change log.
163+
Once all desired features are merged, the release can be executed by merging the release-PR into `main`.
164+
This will trigger actions that create a release on Github, on PyPI and the docs.
165+
166+
167+
### Publishing Manually
168+
157169
Generate distribution package. Make sure you have the latest versions of `setuptools` and `wheel` installed:
158170

159171
```bash

‎setup.cfg‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
description-file = README.md

0 commit comments

Comments
 (0)