@@ -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,63 @@ 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
40
+ NAME="django_iris"-${VERSION}-py3-none-any
41
+ echo ::set-output name=name::$NAME
32
42
- name : Build package
33
43
run : python -m build
34
44
- name : Publish package
35
45
uses : pypa/gh-action-pypi-publish@release/v1.5
36
46
with :
37
47
user : __token__
38
48
password : ${{ secrets.PYPI_API_TOKEN }}
49
+ - name : Create Beta Release
50
+ id : create_release
51
+ if : github.event_name == 'push'
52
+ uses : actions/create-release@v1
53
+ env :
54
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55
+ with :
56
+ tag_name : ${{ steps.set-version.outputs.version }}
57
+ release_name : ${{ steps.set-version.outputs.version }}
58
+ prerelease : ${{ github.event_name != 'release' }}
59
+ - name : Upload Release Asset
60
+ id : upload-release-asset
61
+ uses : actions/upload-release-asset@v1
62
+ env :
63
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64
+ with :
65
+ upload_url : ${{ github.event_name == 'release' && github.event.release.upload_url || steps.create_release.outputs.upload_url }}
66
+ asset_path : dist/${{ steps.set-version.outputs.name }}.whl
67
+ asset_name : ${{ steps.set-version.outputs.name }}.whl
68
+ asset_content_type : application/zip
69
+ - uses : actions/checkout@v2
70
+ if : github.event_name == 'release'
71
+ with :
72
+ ref : main
73
+ - name : Bump version
74
+ if : github.event_name == 'release'
75
+ run : |
76
+ git config --global user.name 'ProjectBot'
77
+ git config --global user.email '[email protected] '
78
+ VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
79
+ VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
80
+ sed -ie "s/version = .*/version = $VERSION/" setup.cfg
81
+ git add setup.cfg
82
+ git commit -m 'auto bump version with release'
83
+ git push
0 commit comments