Skip to content

Commit e9e1ce1

Browse files
authored
Change __version__ on release (#529)
* NO-ISSUE Read version dynamically * NO-ISSUE Bye embedded version * NO-ISSUE Replace __version__ with tag on release * NO-ISSUE Modify test * NO-ISSUE Bye minor version up workflow
1 parent 4a16f1b commit e9e1ce1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+121
-126
lines changed

.github/workflows/auto-testing.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ jobs:
2424
run: |
2525
python -m pip install --upgrade pip
2626
if [ -f requirements-dev.txt ]; then python -m pip install -r requirements-dev.txt; fi
27+
- name: Ensure generate-code.py doesn't throw any error
28+
run: |
29+
python generate-code.py
30+
- name: Update version in linebot/__about__.py
31+
run: |
32+
sed -i 's/__version__ = "__LINE_BOT_SDK_PYTHON_VERSION__"/__version__ = "12.34.5"/g' linebot/__about__.py
33+
cat linebot/__about__.py
2734
- name: Test with pytest
2835
run: |
2936
tox
3037
- name: Ensure README.rst builds correctly for PyPI
3138
run: |
3239
pip install readme-renderer
3340
python -m readme_renderer README.rst >/dev/null
34-
- name: Ensure generate-code.py doesn't throw any error
35-
run: |
36-
python generate-code.py
3741

.github/workflows/bump-minor-version.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Commit generated code to master branch
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Setup
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.x'
22+
- name: Generate code
23+
run: |
24+
python generate-code.py
25+
diff=$(git --no-pager diff --name-only HEAD)
26+
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
27+
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
28+
run: |
29+
git config user.name github-actions
30+
git config user.email github-actions@github.com
31+
git add .
32+
git commit -m "Code are generated by openapi generator"
33+
git push origin master
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-to-pypi.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
run: |
2525
python -m pip install --upgrade pip
2626
pip install setuptools wheel twine
27+
- name: Show Version Number
28+
run: |
29+
echo "Version=${{ github.event.release.tag_name }}"
30+
- name: Update version in linebot/__about__.py
31+
run: |
32+
sed -i 's/__version__ = "__LINE_BOT_SDK_PYTHON_VERSION__"/__version__ = "'${{ github.event.release.tag_name }}'"/g' linebot/__about__.py
33+
cat linebot/__about__.py
2734
- name: Build and publish
2835
env:
2936
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}

generate-code.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def main():
4343
run_command('mvn package -DskipTests=true')
4444
os.chdir("..")
4545

46-
package_version = run_command("grep '__version__ =' linebot/__about__.py | awk -F\"'\" '{print $2}'")
47-
4846
components = [
4947
{"sourceYaml": "channel-access-token.yml", "modelPackage": "linebot.v3.oauth"},
5048
{"sourceYaml": "insight.yml", "modelPackage": "linebot.v3.insight"},
@@ -73,8 +71,7 @@ def main():
7371
--additional-properties=excludeText=true \\
7472
--additional-properties=generateSourceCodeOnly=true \\
7573
--package-name {modelPackage} \\
76-
-i line-openapi/{sourceYaml} \\
77-
--additional-properties=packageVersion={package_version}
74+
-i line-openapi/{sourceYaml}
7875
'''
7976
run_command(command)
8077

generator/src/main/resources/python-nextgen-custom-client/__init__package.mustache

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
{{>partial_header}}
66

7-
__version__ = "{{packageVersion}}"
8-
97
# import apis into sdk package
108
{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}}
119
{{/apis}}{{/apiInfo}}

generator/src/main/resources/python-nextgen-custom-client/api_client.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from {{packageName}}.api_response import ApiResponse
2222
import {{modelPackage}}
2323
from {{packageName}} import rest
2424
from {{packageName}}.exceptions import ApiValueError, ApiException
25-
25+
from linebot.__about__ import __version__
2626

2727
class ApiClient(object):
2828
"""Generic API client for OpenAPI client library builds.
@@ -70,7 +70,7 @@ class ApiClient(object):
7070
self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token
7171
self.cookie = cookie
7272
# Set default User-Agent.
73-
self.user_agent = 'line-bot-sdk-python/{{{packageVersion}}}'
73+
self.user_agent = f"line-bot-sdk-python/{__version__}"
7474
self.client_side_validation = configuration.client_side_validation
7575

7676
{{#asyncio}}

generator/src/main/resources/python-nextgen-custom-client/asyncio/api_client.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from {{packageName}}.api_response import ApiResponse
2222
import {{modelPackage}}
2323
from {{packageName}} import async_rest
2424
from {{packageName}}.exceptions import ApiValueError, ApiException
25-
25+
from linebot.__about__ import __version__
2626

2727
class AsyncApiClient(object):
2828
"""Generic API client for OpenAPI client library builds.
@@ -70,7 +70,7 @@ class AsyncApiClient(object):
7070
self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token
7171
self.cookie = cookie
7272
# Set default User-Agent.
73-
self.user_agent = 'line-bot-sdk-python-async/{{{packageVersion}}}'
73+
self.user_agent = f"line-bot-sdk-python/{__version__}"
7474
self.client_side_validation = configuration.client_side_validation
7575

7676
async def __aenter__(self):

generator/src/main/resources/python-nextgen-custom-client/configuration.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import urllib3
1212

1313
import http.client as httplib
1414
from {{packageName}}.exceptions import ApiValueError
15+
from linebot.__about__ import __version__
1516

1617
JSON_SCHEMA_VALIDATION_KEYWORDS = {
1718
'multipleOf', 'maximum', 'exclusiveMaximum',
@@ -522,8 +523,8 @@ conf = {{{packageName}}}.Configuration(
522523
"OS: {env}\n"\
523524
"Python Version: {pyversion}\n"\
524525
"Version of the API: {{version}}\n"\
525-
"SDK Package Version: {{packageVersion}}".\
526-
format(env=sys.platform, pyversion=sys.version)
526+
"SDK Package Version: {__version__}".\
527+
format(env=sys.platform, pyversion=sys.version, package_version=__version__)
527528

528529
def get_host_settings(self):
529530
"""Gets an array of host settings

linebot/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Meta data of line-bot-sdk."""
1616

1717

18-
__version__ = '3.5.0'
18+
__version__ = "__LINE_BOT_SDK_PYTHON_VERSION__"
1919
__author__ = 'LINE Corporation'
2020
__copyright__ = 'Copyright 2016, LINE Corporation'
2121
__license__ = 'Apache 2.0'

0 commit comments

Comments
 (0)