Skip to content

Commit 46b395f

Browse files
committed
ci update
1 parent 645d5ed commit 46b395f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

.github/workflows/python-publish.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ name: Upload Python Package
1111
on:
1212
release:
1313
types: [published]
14+
push:
15+
branches: [main]
1416

1517
jobs:
1618
deploy:
@@ -19,20 +21,45 @@ jobs:
1921

2022
steps:
2123
- uses: actions/checkout@v2
24+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
25+
if: github.event_name == 'push'
2226
- name: Set up Python
2327
uses: actions/setup-python@v2
2428
with:
2529
python-version: '3.x'
2630
- name: Install dependencies
31+
id: set-version
2732
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))
2936
sed -ie "s/version = .*/version = $VERSION/" setup.cfg
3037
python -m pip install --upgrade pip
3138
pip install build
39+
echo ::set-output name=version::$VERSION
3240
- name: Build package
3341
run: python -m build
3442
- name: Publish package
3543
uses: pypa/gh-action-pypi-publish@release/v1.5
3644
with:
3745
user: __token__
3846
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

Comments
 (0)