Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change the version management method #168

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/update-caret-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ jobs:

- name: Commit and push changes
run: |
sed -i "s/__version__ =.*/__version__ = '${{ steps.tag.outputs.TAG_NAME }}'/" ros2caret/__version__.py
git add ros2caret/__version__.py
sed -i "s/version='.*',/version='$(echo "${{ steps.tag.outputs.TAG_NAME }}" | sed 's/^.//')',/" setup.py
git add setup.py
sed -i "s|<version>.*</version>|<version>$(echo "${{ steps.tag.outputs.TAG_NAME }}" | sed 's/^.//')</version>|" package.xml
git add package.xml
git commit -m "chore: update version to ${{ steps.tag.outputs.TAG_NAME }}" -s
git push origin ${{ steps.tag.outputs.BRANCH_NAME }}

Expand All @@ -58,7 +60,7 @@ jobs:
run: |
if [ ${{ steps.tag.outputs.LATEST_TAG_NAME }} == ${{ steps.tag.outputs.TAG_NAME }} ]; then
gh pr create --title "chore: update version to ${{ steps.tag.outputs.TAG_NAME }}" \
--body "This pull request updates the version in __version__.py to ${{ steps.tag.outputs.TAG_NAME }}" \
--body "This pull request updates the version in setup.py & package.xml to ${{ steps.tag.outputs.TAG_NAME }}" \
--base main \
--head ${{ steps.tag.outputs.BRANCH_NAME }}
fi
Expand Down
15 changes: 0 additions & 15 deletions ros2caret/__version__.py

This file was deleted.

23 changes: 20 additions & 3 deletions ros2caret/verb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,28 @@

from ros2caret.verb import VerbExtension

from ..__version__ import __version__
import os.path
import codecs
import re


class CaretVersionVerb(VerbExtension):

def main(self, *, args):
version = __version__
print(version)
version_path = '../../setup.py'
version = self.get_version(version_path)
print('v' + version)

def read(self,rel_path):
here_path = os.path.dirname(os.path.realpath(__file__))
with codecs.open(os.path.join(here_path, rel_path), 'r') as fp:
return fp.read()

def get_version(self,rel_path):
version_pattern = re.compile(r"\s*version\s*=\s*['\"](\d+\.\d+\.\d+)['\"]")
for line in self.read(rel_path).splitlines():
match = version_pattern.search(line)
if match:
return match.group(1)
else:
raise RuntimeError("Unable to find version string.")
9 changes: 1 addition & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
from __future__ import annotations

import os

from setuptools import setup


package_name = 'ros2caret'
ns: dict[str, str] = {}

version_path = f'{os.path.dirname(os.path.realpath(__file__))}/ros2caret/__version__.py'
with open(version_path, 'r') as f:
eval(compile(f.read(), version_path, 'exec'), ns)

setup(
name=package_name,
version=ns['__version__'],
version='0.4.24',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
Expand Down
Loading