-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (52 loc) · 1.69 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
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3
- name: Install dependencies
run: |
pip install hatch twine
- name: Set DATE variable
run: echo "DATE=$(date +%Y.%-m.%-d)" >> $GITHUB_ENV
- name: Display date
run: echo "date ${{ env.DATE }}"
- name: Set initial TAG_NUMBER
run: echo "TAG_NUMBER=1" >> $GITHUB_ENV
- name: Get last tag
id: get_last_tag
run: echo "LAST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Display last tag
run: echo "last tag ${{ env.LAST_TAG }}"
- name: Determine new tag
run: |
if [[ "${{ env.LAST_TAG }}" == *"${{ env.DATE }}"* ]]; then
echo "is today"
echo "${{ env.LAST_TAG##*. }}"
echo "TAG_NUMBER=$((${{ env.LAST_TAG##*. }} + 1))" >> $GITHUB_ENV
fi
echo "NEW_TAG=${{ env.DATE }}.${{ env.TAG_NUMBER }}" >> $GITHUB_ENV
- name: Display new tag
run: echo "Creating tag ${{ env.NEW_TAG }}"
- name: Create and push tag
run: |
git tag "${{ env.NEW_TAG }}"
git push origin "${{ env.NEW_TAG }}"
- name: Update version with hatch
run: hatch version ${{ env.NEW_TAG }}
- name: Build with hatch
run: hatch build
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: twine upload dist/*