@@ -11,6 +11,8 @@ name: Upload Python Package
11
11
on :
12
12
release :
13
13
types : [published]
14
+ push :
15
+ branches : [main]
14
16
15
17
jobs :
16
18
deploy :
@@ -19,20 +21,45 @@ jobs:
19
21
20
22
steps :
21
23
- uses : actions/checkout@v2
24
+ - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
25
+ if : github.event_name == 'push'
22
26
- name : Set up Python
23
27
uses : actions/setup-python@v2
24
28
with :
25
29
python-version : ' 3.x'
26
30
- name : Install dependencies
31
+ id : set-version
27
32
run : |
28
- VERSION=${{ github.event.release.tag_name }}
33
+ VERSION=$(grep version setup.cfg | cut -d= -f2 | tr -d '[:blank:]')
34
+ [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
35
+ [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=b && VERSION+=$(($(git tag -l "*$VERSION*" | cut -db -f2 | sort -n | tail -1)+1))
29
36
sed -ie "s/version = .*/version = $VERSION/" setup.cfg
30
37
python -m pip install --upgrade pip
31
38
pip install build
39
+ echo ::set-output name=version::$VERSION
32
40
- name : Build package
33
41
run : python -m build
34
42
- name : Publish package
35
43
uses : pypa/gh-action-pypi-publish@release/v1.5
36
44
with :
37
45
user : __token__
38
46
password : ${{ secrets.PYPI_API_TOKEN }}
47
+ - name : Create Beta Release
48
+ id : create_release
49
+ if : github.event_name == 'push'
50
+ uses : actions/create-release@v1
51
+ env :
52
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53
+ with :
54
+ tag_name : v${{ steps.set-version.outputs.version }}
55
+ release_name : v${{ steps.set-version.outputs.version }}
56
+ prerelease : ${{ github.event_name != 'release' }}
57
+ - name : Bump version
58
+ if : github.event_name == 'release'
59
+ run : |
60
+ VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
61
+ sed -ie "s/version = .*/version = $VERSION/" setup.cfg
62
+ git checkout main
63
+ git add setup.cfg
64
+ git commit -m 'auto bump version with release'
65
+ git push
0 commit comments