-
Notifications
You must be signed in to change notification settings - Fork 303
82 lines (81 loc) · 2.52 KB
/
release.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
78
79
80
81
82
name: Release package
on:
workflow_dispatch:
inputs:
release-type:
type: choice
description: 'Release type (one of): patch, minor, major, prepatch, preminor, premajor, prerelease'
default: 'patch'
options:
- 'patch'
- 'minor'
- 'major'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
# Checkout project repository
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.5"
- name: Install dependencies
run: |
poetry install
- name: Run Python lint checks
run: |
poetry run pre-commit run --all-files
- name: Run Python tests
run: |
poetry run pytest --cov
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Bump release version
run: |
poetry version ${{ github.event.inputs.release-type }}
echo "NEW_VERSION=$(poetry version --short)" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
- name: Build package
run: |
poetry lock
poetry build
- name: Commit pyproject.toml and poetry.lock
run: |
git add pyproject.toml poetry.lock
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
git push origin master
- name: Build docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Push repository changes
- name: Publish package
run: |
poetry publish --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
- name: Push docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}