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
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dbab790
chore: add test action
BalduinLandolt e86aa6e
chore: add setup.cfg
BalduinLandolt 1d505ee
chore: add pr-title-check, release-please and release workflow
BalduinLandolt 8a71c60
chore: add PR template
BalduinLandolt b66aa62
docs: update documentation according to automated release process
BalduinLandolt e015ba3
fix: correct package name
BalduinLandolt d5c185f
chore: add notification action
BalduinLandolt ef52e7b
chore: improve PR title Regex
BalduinLandolt ed93eb8
chore: add upper case to PR title regex
BalduinLandolt File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: dsp-tools | ||
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 }]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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 to PyPI | ||
release-pypi: | ||
name: Release to PyPI | ||
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-docs: | ||
name: Release 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 latest docs | ||
- run: make publish-docs | ||
|
||
notification: | ||
name: Google chat notification about release and published version | ||
needs: [release-pypi, release-docs] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Send notification to google chat room "DSP releases" | ||
uses: lakto/google-chat-action@main | ||
with: | ||
url: ${{ secrets.GOOGLE_CHAT_DSP_RELEASES_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
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 notDSP-
.There was a problem hiding this comment.
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.)There was a problem hiding this comment.
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+\)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are reading my thoughts :-)
no idea
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ;-)