-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (75 loc) · 2.33 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: kellog
on:
push:
branches:
- '**'
tags:
- 'v*'
workflow_dispatch:
inputs:
python-version:
description: Python version
required: true
type: choice
options:
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11
- 3.12
jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{fromJson(github.event.inputs.python-version || '["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]')}}
steps:
- uses: actions/checkout@v4
- name: Run Ruff checks
uses: chartboost/ruff-action@v1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install with dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Unit tests
run: pytest --disable-warnings -vvs kellog/tests
release:
name: Create release
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Extract changelog
id: extract_changelog
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
PREVIOUS_VERSION=$(git tag | sort -rV | sed -n '2p')
CHANGELOG=$(awk -v version="$VERSION" '/^## /{p=0} $0 ~ "^## " version{p=1} p' CHANGELOG.md)
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_OUTPUT
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
body: |
${{ steps.extract_changelog.outputs.CHANGELOG }}
**Full Changelog**: https://github.com/celynw/kellog/compare/${{ steps.extract_changelog.outputs.PREVIOUS_VERSION }}...${{ steps.get_version.outputs.VERSION }}
draft: true
prerelease: false