Skip to content

Commit

Permalink
fix!: add workflows for release automation (#38)
Browse files Browse the repository at this point in the history
Publishes the Errbot as
- Docker: ghcr.io/hapag-lloyd/errbot-hl
- PyPi: https://pypi.org/project/errbot-hl/

Features:
- activates Renovate to update the dependencies regularly
- sets the release version automatically in `version.py`
- pushes every release to the Docker registry and PyPi
- automates the whole release process for GitHub
- lints the pull request

Note: This pull request reads "fix!" as we want a major release as there
are breaking changes in the unreleased code of the forked repository.

---------

Co-authored-by: generate-app-token-hl[bot] <151022333+generate-app-token-hl[bot]@users.noreply.github.com>
Co-authored-by: generate-app-token-hl[bot] <generate-app-token-hl[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 18, 2023
1 parent 0080eff commit 93ee796
Show file tree
Hide file tree
Showing 15 changed files with 307 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["github>Hapag-Lloyd/Renovate-Global-Configuration"]
}
18 changes: 18 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: clean packages

on:
schedule:
- cron: '30 1 * * 1'

jobs:
clean_packages:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/delete-package-versions@v4
with:
package-name: errbot
package-type: container
# do not delete releases
ignore-versions: '^\d+\.\d+\.\d+$'
20 changes: 9 additions & 11 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
name: build docker image

on:
push:
branches:
- master
pull_request:
release:
types: [published]

permissions:
contents: read
packages: write

jobs:
build:
if: github.repository_owner == 'errbotio'
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/[email protected]

- name: build and push docker image
- name: build and push image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: errbotio/errbot
tags: latest
registry: docker.io
dockerfile: Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
image: errbot-hl
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- reopened
- synchronize

jobs:
main:
name: Lint PR title
runs-on: ubuntu-latest
permissions:
pull-requests: read
contents: read
statuses: write
steps:
- uses: amannn/action-semantic-pull-request@47b15d52c5c30e94a17ec87eb8dd51ff5221fed9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
build
chore
ci
docs
feat
fix
perf
refactor
revert
style
test
# Configure which scopes are allowed.
# deps - dependency updates
# master - for release-please (scope used for releases)
scopes: |
deps
master
requireScope: false
# ensure that the subject doesn't start with an uppercase character.
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
50 changes: 50 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
release:
types: [published]

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install pypa/build
run: >-
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/errbot-hl # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 1 addition & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

Expand All @@ -19,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/[email protected]
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Release

on: # yamllint disable-line rule:truthy
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GET_TOKEN_APP_ID }}
private-key: ${{ secrets.GET_TOKEN_PRIVATE_KEY }}
# bootstrap-sha and release-as needs to be removed after first release
- name: Release
uses: google-github-actions/release-please-action@1ddb669c677d585663a83fc535edc428954c4aeb # ratchet:google-github-actions/release-please-action@v3
with:
release-type: python
token: ${{ steps.app-token.outputs.token }}
include-v-in-tag: false
pull-request-header: ''
bootstrap-sha: cb9e671b30bac5976c51300e820e95db74a8be0f
last-release-sha: 0001618fb3f5986f5b4033f98edee5baa7df5b89
39 changes: 39 additions & 0 deletions .github/workflows/update_release_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Auto update release version

on: # yamllint disable-line rule:truthy
push:
branches:
- release-please--branches--master

jobs:
set-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 # ratchet:actions/checkout@v3
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Set release version
id: set_release_version
env:
HEAD_COMMIT_TITLE: ${{ github.event.head_commit.message }}
run: |
file=$(find . -name "version.py")
version_number=${HEAD_COMMIT_TITLE##* }
sed -i "s/^VERSION .*$/VERSION = \"$version_number\"/" $file
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: set release version
94 changes: 94 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Changelog

## [6.1.21](https://github.com/Hapag-Lloyd/errbot/compare/6.1.20...6.1.21) (2023-11-17)


### Bug Fixes

* fix the tests ([#36](https://github.com/Hapag-Lloyd/errbot/issues/36)) ([7178eb2](https://github.com/Hapag-Lloyd/errbot/commit/7178eb2fa38e40ddac2648fe3a10280fbaccb641))

## [6.1.20](https://github.com/Hapag-Lloyd/errbot/compare/6.1.19...6.1.20) (2023-11-17)


### Bug Fixes

* remove `changes` from `setup.py` ([#34](https://github.com/Hapag-Lloyd/errbot/issues/34)) ([20ab0cc](https://github.com/Hapag-Lloyd/errbot/commit/20ab0cca141f9ad3016f94b1fd3770effe029626))

## [6.1.19](https://github.com/Hapag-Lloyd/errbot/compare/6.1.18...6.1.19) (2023-11-17)


### Bug Fixes

* add `read()` again ([#32](https://github.com/Hapag-Lloyd/errbot/issues/32)) ([65c0a4e](https://github.com/Hapag-Lloyd/errbot/commit/65c0a4eb067db3ce6e25cb51baa5c2cb2c50bbf2))

## [6.1.18](https://github.com/Hapag-Lloyd/errbot/compare/6.1.17...6.1.18) (2023-11-17)


### Bug Fixes

* do not check if release notes were added ([#30](https://github.com/Hapag-Lloyd/errbot/issues/30)) ([32ac9a8](https://github.com/Hapag-Lloyd/errbot/commit/32ac9a8997263ef2a60f160b5112d7ff75855905))

## [6.1.17](https://github.com/Hapag-Lloyd/errbot/compare/6.1.16...6.1.17) (2023-11-17)


### Bug Fixes

* add closing `"` ([#26](https://github.com/Hapag-Lloyd/errbot/issues/26)) ([f684d40](https://github.com/Hapag-Lloyd/errbot/commit/f684d400250d5a8c0be83bf88a8ed68cf13194db))
* dump context ([#28](https://github.com/Hapag-Lloyd/errbot/issues/28)) ([b8e8903](https://github.com/Hapag-Lloyd/errbot/commit/b8e8903733b12cbe648d8c2004d66730338e8ed6))
* get version number from commit message ([#29](https://github.com/Hapag-Lloyd/errbot/issues/29)) ([8e3b6d1](https://github.com/Hapag-Lloyd/errbot/commit/8e3b6d189c402ab47d8ee8d70ba6a3848f9016c1))
* set release version in `version.py` ([#24](https://github.com/Hapag-Lloyd/errbot/issues/24)) ([ac26dcf](https://github.com/Hapag-Lloyd/errbot/commit/ac26dcf61f78ff2f87b5c8bcf70b911810cfb999))
* show PR title ([#27](https://github.com/Hapag-Lloyd/errbot/issues/27)) ([614d1ed](https://github.com/Hapag-Lloyd/errbot/commit/614d1ed92e10703ce2f38d47ca36eb2d285231f7))

## [6.1.16](https://github.com/Hapag-Lloyd/errbot/compare/6.1.15...6.1.16) (2023-11-17)


### Bug Fixes

* use standard token ([#22](https://github.com/Hapag-Lloyd/errbot/issues/22)) ([4b028f8](https://github.com/Hapag-Lloyd/errbot/commit/4b028f81cc4b35c421732a22fe61b47d799a71bd))

## [6.1.15](https://github.com/Hapag-Lloyd/errbot/compare/6.1.14...6.1.15) (2023-11-17)


### Bug Fixes

* change project name to `errbot-hl` ([#20](https://github.com/Hapag-Lloyd/errbot/issues/20)) ([9e5b066](https://github.com/Hapag-Lloyd/errbot/commit/9e5b0664c2e624e09ccbe0bfb9e7c791623206d5))

## [6.1.14](https://github.com/Hapag-Lloyd/errbot/compare/6.1.13...6.1.14) (2023-11-17)


### Bug Fixes

* upload for a published release only ([#18](https://github.com/Hapag-Lloyd/errbot/issues/18)) ([4c54589](https://github.com/Hapag-Lloyd/errbot/commit/4c545893005aebb3208d5f72823e7a8a31dd50a5))

## [6.1.13](https://github.com/Hapag-Lloyd/errbot/compare/6.1.12...6.1.13) (2023-11-17)


### Bug Fixes

* update for release only ([#16](https://github.com/Hapag-Lloyd/errbot/issues/16)) ([ac2b317](https://github.com/Hapag-Lloyd/errbot/commit/ac2b31748bb6acb06cec9ead5e7de79ecdc06413))

## [6.1.12](https://github.com/Hapag-Lloyd/errbot/compare/6.1.11...6.1.12) (2023-11-17)


### Bug Fixes

* show verbose upload to PyPi ([#13](https://github.com/Hapag-Lloyd/errbot/issues/13)) ([f3386d9](https://github.com/Hapag-Lloyd/errbot/commit/f3386d987d0ef7af24aedadae524078e73f4d8ae))

## [6.1.11](https://github.com/Hapag-Lloyd/errbot/compare/6.1.10...6.1.11) (2023-11-17)


### Bug Fixes

* update for release ([#11](https://github.com/Hapag-Lloyd/errbot/issues/11)) ([eeb3e2c](https://github.com/Hapag-Lloyd/errbot/commit/eeb3e2ceb4ebccea2e6e9b664e72bf78fbec3e01))

## [6.1.10](https://github.com/Hapag-Lloyd/errbot/compare/6.1.9...6.1.10) (2023-11-16)


### Bug Fixes

* broken integration tests ([#1668](https://github.com/Hapag-Lloyd/errbot/issues/1668)) ([9373e9e](https://github.com/Hapag-Lloyd/errbot/commit/9373e9ebc7b0b8c2ad17c5ccb5a38f08692068ad))


### Documentation

* add readthedocs yaml config ([#1661](https://github.com/Hapag-Lloyd/errbot/issues/1661)) ([b6acb81](https://github.com/Hapag-Lloyd/errbot/commit/b6acb8150265a614c32248b758a822261b9fea57))
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v9.9.9 (unreleased)
v7.0.0
-------------------

breaking:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN apt update && \
apt install -y git && \
cd /wheel && \
pip3 -vv install --no-cache-dir --no-index --find-links /wheel \
errbot errbot[${INSTALL_EXTRAS}] && \
errbot-hl errbot-hl[${INSTALL_EXTRAS}] && \
rm -rf /wheel /var/lib/apt/lists/*
RUN useradd -m errbot

Expand Down
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@

|
Note: This is a forked version of Errbot. The main reason was, to be able to have an automated release process and release the
changes often. The base for this fork was version 6.1.9 (commit: 7609f6c) from June 2023. The first released version here is
7.0.0 and contains all unreleased changes up to commit 0080eff1324930207f021f55674d5240abae172d from 2023-10-30.

- Docker image: `ghcr.io/hapag-lloyd/errbot-hl <https://github.com/Hapag-Lloyd/errbot/pkgs/container/errbot>`__
- PyPi package: `errbot-hl <https://pypi.org/project/errbot-hl/>`__


Errbot
======
Expand Down
2 changes: 1 addition & 1 deletion errbot/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Just the current version of Errbot.
# It is used for deployment on pypi AND for version checking at plugin load time.
VERSION = "9.9.9" # leave it at 9.9.9 on master until it is branched to a version.
VERSION = "6.1.21"
Loading

0 comments on commit 93ee796

Please sign in to comment.