Skip to content

Commit

Permalink
CI: Release via GH Actions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Calychas authored Nov 16, 2023
1 parent 028e0f8 commit 51e74ef
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 42 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/bump-and-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "Bump ⬆️ library version and create PR"
on:
workflow_dispatch:
inputs:
bumpType:
description: "Bump type"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major

env:
PYTHON_VERSION: 3.11

jobs:
bump-n-pr:
name: Bump ⬆️ and create a Pull Request with a new library version (${{ inputs.bumpType }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Configure Git user
run: |
git config --local user.name "Kraina CI/CD"
git config --local user.email "[email protected]"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: pdm-project/setup-pdm@v3
name: Setup PDM (Python 3.11)
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Install dependencies
run: pdm install -d -G dev --skip=post_install
- name: Bump changelog version
id: changelog
uses: release-flow/keep-a-changelog-action@v2
with:
command: bump
version: ${{ inputs.bumpType }}
tag-prefix: ""
keep-unreleased-section: True
- name: Run bumpver
run: |
pdm run bumpver update --allow-dirty --${{ inputs.bumpType }} -vvv
- name: Get commit message
id: commit_message
run: |
echo COMMIT_MESSAGE="$(git log -1 --pretty=%B | cat)" >> $GITHUB_OUTPUT
- name: Get new version
id: new_version
run: |
pdm run bumpver show -n -e | grep CURRENT_VERSION >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: ${{ steps.commit_message.outputs.COMMIT_MESSAGE }}
branch: ${{ format('release/{0}', steps.new_version.outputs.CURRENT_VERSION) }}
labels: release
base: main
body: ${{ steps.changelog.outputs.release-notes }}
20 changes: 20 additions & 0 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ jobs:
name: "Run tests job"
uses: ./.github/workflows/_tests.yml

github-release:
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
name: Create a GitHub release
needs: [run-tests]
runs-on: ubuntu-latest
steps:
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
- name: Extract version
id: extract-version
uses: winterjung/split@v2
with:
msg: ${{ github.event.head_commit.message }}
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.extract-version.outputs._5 }}
body: ${{ steps.extract-release-notes.outputs.release_notes }}

build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
needs: [run-tests]
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- CI release via GitHub Actions

### Changed

### Deprecated
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SHELL := /bin/bash

install:
pdm install -dG:all

bump:
bumpver update --patch

docs:
mkdocs serve --livereload -w srai

test:
pytest -n auto

.PHONY: install bump docs test

0 comments on commit 51e74ef

Please sign in to comment.