-
Notifications
You must be signed in to change notification settings - Fork 87
81 lines (67 loc) · 2.29 KB
/
release.yaml
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
name: Release
#
# Releases new version of this project.
#
# Make sure to prepare project for a new release (see docs for more). After
# publishing package a GitHub release is drafted. Will fail if the the version
# is already available on PyPI.
#
# Project page on PyPI: https://pypi.org/project/prometheus-fastapi-instrumentator
#
on:
push:
tags:
- v*.*.*
permissions:
contents: write
env:
poetry_version: "2.0.1"
python_version: "3.12"
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ------------------------------------------------------------------------
# Python & Poetry.
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Cache Poetry installation
uses: actions/cache@v4
with:
path: |
~/.local/bin/poetry
~/.local/share/pypoetry
key: |-
${{ runner.os }}-poetry-installation-${{ env.python_version }}-${{ env.poetry_version }}-0
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python -
env:
POETRY_VERSION: ${{ env.poetry_version }}
# ------------------------------------------------------------------------
# Publishing & draft release.
- name: Check version equality between Poetry and __version__
run: |
pattern="__version__ = \"$(poetry version --short)\""
if ! grep -q -R -F --include="__init__.py" "$pattern" src; then
echo "::error::No version equality between Poetry and __version__."; exit 1
fi
- name: Check version equality between Poetry and Git tag
run: |
poetry_version=$(poetry version --short)
git_tag=${GITHUB_REF#refs/*/}
if [[ "v$poetry_version" != "$git_tag" ]]; then
echo "::error::No version equality between Poetry and Git tag."; exit 1
fi
- name: Publish to PyPI with Poetry
run: poetry publish --build -n -u __token__ -p "$TOKEN"
env:
TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Draft GitHub release
uses: softprops/action-gh-release@v2
with:
draft: true