Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: automate release process (DSP-1492) #52

Merged
merged 9 commits into from Apr 8, 2021
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
@@ -0,0 +1,9 @@
===REMOVE===

Important! Please follow the new guidelines for naming Pull Requests: https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-guidelines

> **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.

===REMOVE===

resolves DSP-
20 changes: 20 additions & 0 deletions .github/workflows/ckeck-pr-title.yml
@@ -0,0 +1,20 @@
name: PR-Title

on:
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
test:
name: Check PR Title
runs-on: ubuntu-latest
steps:
# check PR title
- uses: deepakputhraya/action-pr-title@master
with:
regex: '([a-z])+(\(([a-z\-_])+\))?!?: ([a-z])+' # Regex the title should match.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add something like \(DSP-\d+\) to the end of the regex?
By convention, the PR's title should end with "(DSP-123)".

It's is actually missing from this PR's title :-)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all PRs have a task on youtrack. So, this can be tricky. And for example, in another repo I had a task of type PM- and not DSP-.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that it's missing here in the PR title... ;-)
But I also think it might become at some point problematic to enforce it. (There are also some tasks with BS-123. I'm not sure this will be the case in the future, so I think it's a bit risky to enforce this strictly.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make it more general: expect something like: \(.+-\d+\)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however, I leave this up to you

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went even stricter: \([A-Z]+-\d+\)

Do you think it's a problem that I allow only lower case letters in the PR title? Should probably be extended to upper case too, right? (e.g. for abbreviations that often use upper case.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went even stricter: \([A-Z]+-\d+\)

you are reading my thoughts :-)

Do you think it's a problem that I allow only lower case letters in the PR title? Should probably be extended to upper case too, right? (e.g. for abbreviations that often use upper case.)

no idea

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just add upper case, just to be sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can never be too paranoid

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could argue about that ;-)

allowed_prefixes: 'fix,refactor,feat,docs,chore,style,test' # title should start with the given prefix
disallowed_prefixes: 'feature,hotfix,doc' # title should not start with the given prefix
prefix_case_sensitive: true # title prefix are case insensitive
min_length: 7 # Min length of the title
max_length: 60 # Max length of the title
34 changes: 34 additions & 0 deletions .github/workflows/release-please.yml
@@ -0,0 +1,34 @@
name: Release-Please

# triggered when tests complete on main branch
on:
workflow_run:
workflows:
- "Test"
branches:
- main
types:
- completed

jobs:
refused:
# Refuse if tests failed
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure'}}
steps:
- id: refused_step
run: exit 1

release-please:
# Automate releases with Conventional Commit Messages as Pull Requests are merged into "main" branch
name: Prepare next release
runs-on: ubuntu-latest
# release only if tests pass
if: ${{ github.event.workflow_run.conclusion == 'success'}}
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
with:
token: ${{ secrets.GH_TOKEN }}
release-type: python
package-name: gh_action_test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package name is maybe wrong here. This name will be used as prefix in the release

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yes, missed that, thanks

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 }]'
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,38 @@
name: Release

on:
release:
types: [released]

# set environment variables
env:
TOKEN: ${{ secrets.GH_TOKEN }}
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PW }}

jobs:
release-integration:
name: Release to PyPI and make Docs
runs-on: ubuntu-latest
steps:
# check out repo
- uses: actions/checkout@v2
with:
fetch-depth: 1
# install python
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
# install pythonn dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# release new version to PyPI
- run: |
make upgrade-dist-tools
make dist
make upload
# release latest docs
- run: make publish-docs
24 changes: 14 additions & 10 deletions .github/workflows/main.yml → .github/workflows/test.yml
@@ -1,20 +1,22 @@
name: CI
name: Test

on: [push]

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

jobs:
test-integration:
name: Integration Tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
# run tests
- name: Checkout source
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: joschi/setup-jdk@v2
- name: Set up JDK
uses: joschi/setup-jdk@v2
with:
java-version: '11' # The OpenJDK version to make available on the path
architecture: 'x64' # defaults to 'x64'
Expand All @@ -30,8 +32,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install python package dependencies
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
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: run test-integration
run: |
make upgrade-dist-tools
Expand Down
13 changes: 12 additions & 1 deletion README.md
Expand Up @@ -51,7 +51,18 @@ $ make install
$ make test
```

## Publishing to PyPi
## Publishing

Publishing is automated with github actions and should _not_ be done manually.

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).

If this is done correctly, when merging a PR into `main`, the `release-please` action will create or update a release-PR.
This PR will follow semantic versioning and update the change log.
Once all desired features are merged, the release can be executed by merging the release-PR into `main`.
This will trigger actions that create a release on Github, on PyPI and the docs.

### Publishing to PyPi

Generate distribution package. Make sure you have the latest versions of `setuptools` and `wheel` installed.
Remove the `dist`and `buil`-directories: `rm -rf bild dist`
Expand Down
12 changes: 12 additions & 0 deletions docs/index.md
Expand Up @@ -154,6 +154,18 @@ make test

## Publishing

Publishing is automated with github actions and should _not_ be done manually.

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).

If this is done correctly, when merging a PR into `main`, the `release-please` action will create or update a release-PR.
This PR will follow semantic versioning and update the change log.
Once all desired features are merged, the release can be executed by merging the release-PR into `main`.
This will trigger actions that create a release on Github, on PyPI and the docs.


### Publishing Manually

Generate distribution package. Make sure you have the latest versions of `setuptools` and `wheel` installed:

```bash
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md