Skip to content

Commit b233b81

Browse files
committed
script to bump version
1 parent 809e3d3 commit b233b81

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and upload to PyPI
2+
3+
on: [push]
4+
jobs:
5+
build_sdist:
6+
name: Build source distribution
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- uses: actions/setup-python@v2
12+
name: Install Python
13+
with:
14+
python-version: '3.x'
15+
16+
- name: Install deps
17+
run: |
18+
pip install --upgrade pip
19+
pip install setuptools twine wheel
20+
21+
- name: Build sdist
22+
run: python setup.py sdist
23+
24+
- uses: actions/upload-artifact@v2
25+
with:
26+
path: dist/*.tar.gz
27+
28+
upload_pypi:
29+
needs: [build_sdist]
30+
runs-on: ubuntu-latest
31+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
32+
steps:
33+
- uses: actions/download-artifact@v2
34+
with:
35+
name: artifact
36+
path: dist
37+
38+
- uses: pypa/gh-action-pypi-publish@release/v1
39+
with:
40+
user: __token__
41+
password: ${{ secrets.PYPI_TOKEN }}

scripts/update_version.bash

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3+
VER=$1
4+
5+
python3 $DIR/update_version.py --version $VER
6+
7+
8+

scripts/update_version.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import re
3+
import argparse
4+
5+
6+
def replace_in_file(filepath, regex, sub):
7+
with open(filepath, 'r') as f:
8+
content = f.read()
9+
10+
content_new = re.sub(regex, sub, content, flags=re.M)
11+
12+
with open(filepath, "w") as f:
13+
f.write(content_new)
14+
15+
16+
dir_path = os.path.dirname(os.path.realpath(__file__))
17+
parser = argparse.ArgumentParser()
18+
parser.add_argument('--version', help='version to replace')
19+
args = parser.parse_args()
20+
ver = args.version
21+
print("using version " + ver)
22+
23+
about_file = os.path.join(dir_path, os.pardir, "mergin", "version.py")
24+
print("patching " + about_file)
25+
replace_in_file(about_file, "__version__\s=\s'.*", "__version__ = '" + ver + "'")
26+
27+
setup_file = os.path.join(dir_path, os.pardir, "setup.py")
28+
print("patching " + setup_file)
29+
replace_in_file(setup_file, "VERSION\s=\s'.*", "VERSION = '" + ver + "'")

0 commit comments

Comments
 (0)