-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (40 loc) · 1.08 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
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 dependencies
run: |
pip install hatch twine
- 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"
hatch version "$NEW_TAG"
hatch build
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: twine upload dist/*