-
Notifications
You must be signed in to change notification settings - Fork 86
81 lines (67 loc) · 2.45 KB
/
testpypi.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: TestPyPI
#
# Publishes package to TestPyPI using Poetry.
#
# - Can be used safely on all types of commit references.
# - Will fail if the the version is already available on TestPyPI.
# - No tests, sanity checks, or anything like that before release.
#
# Project page on TestPyPI: https://test.pypi.org/project/prometheus-fastapi-instrumentator
#
on:
workflow_dispatch:
inputs:
version:
description: Unique version to release to TestPyPI.
type: string
default: ""
env:
poetry_version: "1.8.2"
python_version: "3.12"
jobs:
testpypi:
name: TestPyPI
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 }}
# ------------------------------------------------------------------------
# Release to TestPyPI.
- name: Adjust package version
if: ${{ inputs.version != '' }}
run: poetry version -- ${{ inputs.version }}
- name: Adjust __version__ variable
if: ${{ inputs.version != '' }}
run: |
pversion="$(poetry version --short)"
sed -i "/^__version__/c\__version__ = \"$pversion\"" src/*/__init__.py
- 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: Configure Poetry repo for TestPyPI
run: poetry config repositories.testpypi https://test.pypi.org/legacy/
- name: Publish to TestPyPI with Poetry
run: poetry publish --build -n -r testpypi -u __token__ -p "$TOKEN"
env:
TOKEN: ${{ secrets.TESTPYPI_TOKEN }}