Skip to content

Commit

Permalink
maint: set new version in dev release
Browse files Browse the repository at this point in the history
  • Loading branch information
wang0618 committed Feb 6, 2021
1 parent cc06cb1 commit 558d4e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/sync_repo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push mirror and assets
name: Sync with mirror repo
on:
push:
branches:
Expand Down Expand Up @@ -27,12 +27,15 @@ jobs:
run: |
pip3 install -e ".[all]"
cd docs && CODE_EXPORT_PATH=../demos/doc_demos make clean text
- name: Set dev version
run: python3 tools/build_dev_version.py
- name: Push
run: |
git fetch --unshallow origin
git remote add aliyun "https://code.aliyun.com/wang0618/pywebio.git"
git config credential.helper '!f() { sleep 1; echo "username=${ALIYUN_GIT_USER}"; echo "password=${ALIYUN_GIT_PASSWORD}"; }; f'
rm .gitignore
git add pywebio/__version__.py
git add pywebio/html/js
git add demos/doc_demos
git config user.email "${ALIYUN_GIT_USER}"
Expand Down
17 changes: 17 additions & 0 deletions tools/build_dev_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import datetime
import os
import re

proj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

version = datetime.datetime.now().strftime('.dev%y%m%d%H%M')
version_path = os.path.join(proj_dir, 'pywebio', '__version__.py')

content = open(version_path).read()
new_content = re.sub(r'__version__ = "(.*)?"', r'__version__ = "\g<1>%s"' % version, content)
new_content += '\n__commit_hash__ = %r' % os.environ.get('GITHUB_SHA', '')[:8]
open(version_path, 'w').write(new_content)

about = {}
exec(new_content, about)
print(about['__version__'])

0 comments on commit 558d4e4

Please sign in to comment.