Skip to content

Commit

Permalink
ci: add GitHub workflows for package version bump and release
Browse files Browse the repository at this point in the history
  • Loading branch information
rgeraskin committed Apr 9, 2024
1 parent 9032a68 commit 24bb36f
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Bump Package Version
"on":
push:
branches:
- master
jobs:
bump-version:
name: Bump Package Version
if: ${{ ! startsWith(github.event.head_commit.message, 'bump:') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Install dependencies
run: pip install commitizen pylint
- name: Cache pre-commit
id: cache-pre-commit
uses: actions/cache@v4
env:
cache-name: cache-pre-commit
with:
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
- name: Run pre-commit
uses: pre-commit/[email protected]
- name: Bump version
id: bump
run: |
git config user.name github-actions
git config user.email [email protected]
cz bump --yes
continue-on-error: true
- name: Push changes
if: steps.bump.outcome == 'success'
run: git push && git push --tags
29 changes: 29 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PR checks
"on":
pull_request:
branches:
- master
jobs:
pre-commit:
name: Run pre-commit checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Install dependencies
run: pip install pylint
- name: Cache pre-commit
id: cache-pre-commit
uses: actions/cache@v4
env:
cache-name: cache-pre-commit
with:
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
- name: Run pre-commit
uses: pre-commit/[email protected]
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release
"on":
push:
tags:
- "*"
jobs:
docker:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ github.ref_name }}
pypi:
name: Build and publish package to PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Install Poetry
run: |
pip install poetry
- name: Build and publish package
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry build
poetry publish
release:
name: Create GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Install Commitizen
run: |
pip install commitizen
- name: Generate Changelog
run: |
git fetch --tags
echo Changes in this Release: | tee release_notes
cz changelog --dry-run ${{ github.ref_name }} | tail -n +2 | tee -a release_notes
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: release_notes
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
rev: v0.38.0
hooks:
- id: markdownlint
args: [--fix, --disable, MD013, MD033, --]
args: [--fix, --disable, MD013, MD033, -i, CHANGELOG.md, --]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.21.3
hooks:
Expand Down
18 changes: 18 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends: default
rules:
braces:
forbid: non-empty
comments:
min-spaces-from-content: 1
comments-indentation: disable
document-start: disable
empty-values: enable
indentation:
spaces: 2
key-ordering: disable
line-length: disable
# allow-non-breakable-words: false
quoted-strings:
quote-type: double
required: only-when-needed
allow-quoted-quotes: true

0 comments on commit 24bb36f

Please sign in to comment.