-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add GitHub workflows for package version bump and release
- Loading branch information
Showing
5 changed files
with
166 additions
and
1 deletion.
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,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 |
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,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] |
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,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 |
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,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 |