-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (50 loc) · 1.37 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
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3
- name: Install poetry
run: |
pip install poetry
- name: Configure poetry
run: |
poetry config virtualenvs.in-project true
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry install
- name: Version tag and build
run: |
DATE=$(date +%Y.%-m.%-d)
LAST_TAG=$(git describe --tags --abbrev=0)
if [[ "$LAST_TAG" == *"$DATE"* ]]; then
TAG_NUMBER=$(echo "$LAST_TAG" | awk -F. '{print $NF}')
TAG_NUMBER=$((TAG_NUMBER + 1))
else
TAG_NUMBER=1
fi
NEW_TAG="$DATE.${TAG_NUMBER}"
git tag "$NEW_TAG"
git push origin "$NEW_TAG"
poetry version "$NEW_TAG"
poetry build
- name: Upload to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
run: poetry publish