semtag 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ - '[0-9]+.[0-9]+.[0-9]+'
8
+ - '[0-9]+.[0-9]+.[0-9]+-*'
9
+
10
+ jobs:
11
+ build-and-publish:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: write # Required for creating GitHub releases
15
+ id-token: write # Required for trusted publishing
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0 # Required for setuptools_scm to get git history
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: '3.x'
27
+
28
+ - name: Install dependencies
29
+ run: |
30
+ python -m pip install --upgrade pip
31
+ pip install build twine
32
+
33
+ - name: Build package
34
+ run: python -m build
35
+
36
+ - name: Check package
37
+ run: twine check dist/*
38
+
39
+ # Use the official PyPI publish action
40
+ - name: Publish to PyPI
41
+ uses: pypa/gh-action-pypi-publish@release/v1
42
+
43
+ # GH Release
44
+ - name: Create GitHub Release
45
+ uses: softprops/action-gh-release@v1
46
+ with:
47
+ generate_release_notes: true
48
+ files: |
49
+ dist/*
50
+
51
+ ### Homebrew tap update
52
+ update-homebrew-tap:
53
+ name: Update Homebrew tap
54
+ runs-on: ubuntu-latest
55
+ needs: build-and-publish
56
+ permissions:
57
+ contents: write
58
+ env:
59
+ FORMULA_PATH: tap/Formula/semtag.rb
60
+ TEMPLATE_PATH: tap/Templates/semtag.template
61
+ steps:
62
+ - name: Checkout this repo
63
+ uses: actions/checkout@v4
64
+ with:
65
+ repository: mateuszmikrut/semtag
66
+ path: semtag
67
+
68
+ - name: Checkout tap repo
69
+ uses: actions/checkout@v4
70
+ with:
71
+ repository: mateuszmikrut/homebrew-tap
72
+ token: ${{ secrets.HOMEBREW_TAP_TOKEN }} ## Add this to secrets
73
+ path: tap
74
+
75
+ - name: Create a branch for the update
76
+ working-directory: tap
77
+ run: |
78
+ set -euo pipefail
79
+ git checkout -b bump-semtag-"${GITHUB_REF_NAME}"
80
+
81
+
82
+ - name: Update formula
83
+ # working-directory: semtag
84
+ run: |
85
+ set -euo pipefail
86
+ TAG="${GITHUB_REF_NAME}"
87
+ VERSION="${TAG#v}"
88
+ TARBALL_URL="https://github.com/mateuszmikrut/semtag/archive/refs/tags/${TAG}.tar.gz"
89
+
90
+ # Get tarball SHA
91
+ curl -sL "$TARBALL_URL" -o semtag.tar.gz
92
+ TARBALL_SHA=$(shasum -a 256 semtag.tar.gz | awk '{print $1}')
93
+
94
+
95
+ RESOURCES=""
96
+ for pkg in $(grep -vE '^#|^$' semtag/requirements.txt ); do
97
+ name=$(echo "$pkg" | sed 's/[>=<].*//')
98
+ version=$(echo "$pkg" | sed 's/.*[>=]=//; s/[<>=].*//')
99
+
100
+ pypi_url="https://pypi.org/pypi/${name}/${version}/json"
101
+ response=$(curl -s "$pypi_url" | tr -d '\r')
102
+
103
+ if ! echo "$response" | jq empty 2>/dev/null; then
104
+ echo "ERROR: Failed to parse PyPI response for $pkg $version" >&2
105
+ continue
106
+ fi
107
+ url=$(echo "$response" | jq -r '.urls[] | select(.packagetype=="sdist") | .url' | head -1)
108
+ sha=$(echo "$response" | jq -r '.urls[] | select(.packagetype=="sdist") | .digests.sha256' | head -1)
109
+
110
+ RESOURCES="$(printf "%s%s\n resource \"%s\" do\n url \"%s\"\n sha256 \"%s\"\n end\n\n" "$RESOURCES" "" "$name" "$url" "$sha")"
111
+ done
112
+ export RESOURCES
113
+
114
+ envsubst < "${{ env.TEMPLATE_PATH }}" > "${{ env.FORMULA_PATH }}"
115
+
116
+ - name: Commit and push changes
117
+ run: |
118
+ set -euo pipefail
119
+ git status --short
120
+ if git diff --quiet; then
121
+ echo "No changes to commit"
122
+ exit 0
123
+ fi
124
+ git config user.name "github-actions[bot]"
125
+ git config user.email "github-actions[bot]@users.noreply.github.com"
126
+ git add "${FORMULA_PATH}"
127
+ git commit -m "Update semtag to ${GITHUB_REF_NAME}"
128
+ git push
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: semtag
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A tool for managing semantic version tags in git repositories
5
5
  Author-email: Mateusz Mikrut <mateusz.mikrut@gmail.com>
6
6
  License-Expression: MIT
@@ -35,16 +35,21 @@ semtag [options]
35
35
 
36
36
  ### Options
37
37
 
38
- - `-p, --patch` - Increment patch version (x.x.PATCH)
39
- - `-m, --minor` - Increment minor version (x.MINOR.0)
40
- - `-M, --major` - Increment major version (MAJOR.0.0)
41
- - `-b, --by` - Increment by a specific number (default: 1)
42
- - `-l, --label` - Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
43
- - `-u, --push` - Push the new tag to remote repository
44
- - `-U, --pushall` - Push all local tags to remote repository
45
- - `-n, --nofetch` - Do not fetch tags from remote prior creating new one
46
- <!-- - `-f, --force` - Force operation even if not on main/master branch -->
47
- - `-v, --verbose` - Increase verbosity (use -v or -vv for more detail (INFO,DEBUG))
38
+ <!-- OPTIONS:START -->
39
+ ```
40
+ -h, --help show this help message and exit
41
+ -v, --verbose Verbosity (-v for INFO, -vv for DEBUG)
42
+ -b, --by BY Increment by a specific number
43
+ -p, --patch Increment patch version (x.x.PATCH)
44
+ -m, --minor Increment minor version (x.MINOR.0)
45
+ -M, --major Increment major version (MAJOR.0.0)
46
+ -l, --label LABEL Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
47
+ -a, --msg MSG Annotated tags message
48
+ -u, --push Push the new tag to remote repository
49
+ -U, --pushall Push all local tags to remote repository
50
+ -n, --no-fetch Do not fetch tags from remote before operation
51
+ ```
52
+ <!-- OPTIONS:END -->
48
53
 
49
54
  ### Examples
50
55
 
@@ -69,6 +74,12 @@ Using pip (preferred)
69
74
  pip install semtag
70
75
  ```
71
76
 
77
+ Using Homebrew
78
+
79
+ ```bash
80
+ brew install mateuszmikrut/tap/semtag
81
+ ```
82
+
72
83
  From git
73
84
  ```bash
74
85
  git clone https://github.com/mateuszmikrut/semtag.git
@@ -10,16 +10,21 @@ semtag [options]
10
10
 
11
11
  ### Options
12
12
 
13
- - `-p, --patch` - Increment patch version (x.x.PATCH)
14
- - `-m, --minor` - Increment minor version (x.MINOR.0)
15
- - `-M, --major` - Increment major version (MAJOR.0.0)
16
- - `-b, --by` - Increment by a specific number (default: 1)
17
- - `-l, --label` - Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
18
- - `-u, --push` - Push the new tag to remote repository
19
- - `-U, --pushall` - Push all local tags to remote repository
20
- - `-n, --nofetch` - Do not fetch tags from remote prior creating new one
21
- <!-- - `-f, --force` - Force operation even if not on main/master branch -->
22
- - `-v, --verbose` - Increase verbosity (use -v or -vv for more detail (INFO,DEBUG))
13
+ <!-- OPTIONS:START -->
14
+ ```
15
+ -h, --help show this help message and exit
16
+ -v, --verbose Verbosity (-v for INFO, -vv for DEBUG)
17
+ -b, --by BY Increment by a specific number
18
+ -p, --patch Increment patch version (x.x.PATCH)
19
+ -m, --minor Increment minor version (x.MINOR.0)
20
+ -M, --major Increment major version (MAJOR.0.0)
21
+ -l, --label LABEL Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
22
+ -a, --msg MSG Annotated tags message
23
+ -u, --push Push the new tag to remote repository
24
+ -U, --pushall Push all local tags to remote repository
25
+ -n, --no-fetch Do not fetch tags from remote before operation
26
+ ```
27
+ <!-- OPTIONS:END -->
23
28
 
24
29
  ### Examples
25
30
 
@@ -44,6 +49,12 @@ Using pip (preferred)
44
49
  pip install semtag
45
50
  ```
46
51
 
52
+ Using Homebrew
53
+
54
+ ```bash
55
+ brew install mateuszmikrut/tap/semtag
56
+ ```
57
+
47
58
  From git
48
59
  ```bash
49
60
  git clone https://github.com/mateuszmikrut/semtag.git
@@ -0,0 +1,3 @@
1
+ gitdb==4.0.12
2
+ GitPython==3.1.45
3
+ smmap==5.0.2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: semtag
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A tool for managing semantic version tags in git repositories
5
5
  Author-email: Mateusz Mikrut <mateusz.mikrut@gmail.com>
6
6
  License-Expression: MIT
@@ -35,16 +35,21 @@ semtag [options]
35
35
 
36
36
  ### Options
37
37
 
38
- - `-p, --patch` - Increment patch version (x.x.PATCH)
39
- - `-m, --minor` - Increment minor version (x.MINOR.0)
40
- - `-M, --major` - Increment major version (MAJOR.0.0)
41
- - `-b, --by` - Increment by a specific number (default: 1)
42
- - `-l, --label` - Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
43
- - `-u, --push` - Push the new tag to remote repository
44
- - `-U, --pushall` - Push all local tags to remote repository
45
- - `-n, --nofetch` - Do not fetch tags from remote prior creating new one
46
- <!-- - `-f, --force` - Force operation even if not on main/master branch -->
47
- - `-v, --verbose` - Increase verbosity (use -v or -vv for more detail (INFO,DEBUG))
38
+ <!-- OPTIONS:START -->
39
+ ```
40
+ -h, --help show this help message and exit
41
+ -v, --verbose Verbosity (-v for INFO, -vv for DEBUG)
42
+ -b, --by BY Increment by a specific number
43
+ -p, --patch Increment patch version (x.x.PATCH)
44
+ -m, --minor Increment minor version (x.MINOR.0)
45
+ -M, --major Increment major version (MAJOR.0.0)
46
+ -l, --label LABEL Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
47
+ -a, --msg MSG Annotated tags message
48
+ -u, --push Push the new tag to remote repository
49
+ -U, --pushall Push all local tags to remote repository
50
+ -n, --no-fetch Do not fetch tags from remote before operation
51
+ ```
52
+ <!-- OPTIONS:END -->
48
53
 
49
54
  ### Examples
50
55
 
@@ -69,6 +74,12 @@ Using pip (preferred)
69
74
  pip install semtag
70
75
  ```
71
76
 
77
+ Using Homebrew
78
+
79
+ ```bash
80
+ brew install mateuszmikrut/tap/semtag
81
+ ```
82
+
72
83
  From git
73
84
  ```bash
74
85
  git clone https://github.com/mateuszmikrut/semtag.git
@@ -11,4 +11,5 @@ semtag.egg-info/SOURCES.txt
11
11
  semtag.egg-info/dependency_links.txt
12
12
  semtag.egg-info/entry_points.txt
13
13
  semtag.egg-info/requires.txt
14
- semtag.egg-info/top_level.txt
14
+ semtag.egg-info/top_level.txt
15
+ tools/pre-commit
@@ -14,19 +14,12 @@ logger = logging.getLogger(__name__)
14
14
 
15
15
  def main():
16
16
  """ Main function """
17
- ########################
18
- ### Argument Parsing ###
19
- ########################
17
+
18
+ ### Arguments
20
19
  parser = argparse.ArgumentParser(
21
20
  description='SemTag - Manage semantic version tags in git repositories',
22
21
  formatter_class=argparse.RawDescriptionHelpFormatter,
23
- epilog="""
24
- Examples:
25
- %(prog)s -m # Increment minor version (1.0.0 -> 1.1.0)
26
- %(prog)s -M # Increment major version (1.0.0 -> 2.0.0)
27
- %(prog)s -p -b 5 # Increment patch version by 5 (1.0.0 -> 1.0.5)
28
- %(prog)s -p -l rc1 # Increment patch and add label (1.0.0 -> 1.0.1-rc1)
29
- """
22
+ epilog="\n"
30
23
  )
31
24
  parser.add_argument('-v', '--verbose', action='count', default=0, help='Verbosity (-v for INFO, -vv for DEBUG)')
32
25
  # parser.add_argument('-f', '--force', action='store_true', default=False, help='Force the operation even if not on main/master branch')
@@ -38,12 +31,13 @@ Examples:
38
31
  version_group.add_argument('-M', '--major', action='store_true', help='Increment major version (MAJOR.0.0)')
39
32
 
40
33
  parser.add_argument('-l', '--label', type=str, default=None, help='Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)')
34
+ parser.add_argument('-a', '--msg', type=str, help='Annotated tags message', default=None)
41
35
  parser.add_argument('-u', '--push', action='store_true', help='Push the new tag to remote repository', default=False)
42
36
  parser.add_argument('-U', '--pushall', action='store_true', help='Push all local tags to remote repository', default=False)
43
37
  parser.add_argument('-n', '--no-fetch', action='store_true', help='Do not fetch tags from remote before operation', default=False)
44
38
  args = parser.parse_args()
45
39
 
46
- ### Logging based on verbosity ###
40
+ ### Logging based on verbosity
47
41
  if args.verbose == 0:
48
42
  log_level = logging.WARNING
49
43
  elif args.verbose == 1:
@@ -55,14 +49,12 @@ Examples:
55
49
  level=log_level,
56
50
  format='%(message)s' # Keep it simple (no timestamps, severity etc.)
57
51
  )
58
-
59
- ##################
60
- ### Main Logic ###
61
- ##################
52
+
53
+ ### Main Logic
62
54
  logger.debug(f"Arguments: {args}")
63
55
  pwd = Path('.').resolve()
64
56
 
65
- ### Check if this is a git workspace ###
57
+ ### Check if this is a git workspace
66
58
  try:
67
59
  repo = git.Repo(pwd, search_parent_directories=True)
68
60
  logger.debug(f"Found git repository at {repo.working_dir}")
@@ -85,8 +77,7 @@ Examples:
85
77
  # logger.warning("HEAD is detached, not on any branch")
86
78
  # exit(2)
87
79
 
88
-
89
- # Fetch tags from remote to avoid duplicates
80
+ ### Fetch tags from remote to avoid duplicates
90
81
  if not args.no_fetch:
91
82
  try:
92
83
  logger.debug("Fetching tags from remote...")
@@ -94,22 +85,23 @@ Examples:
94
85
  logger.info("Tags fetched successfully")
95
86
  except Exception as e:
96
87
  logger.warning(f"Error fetching tags: {e}")
97
-
98
- logger.debug(f"Tags in repository: {repo.tags}")
88
+
89
+ ### Sort and filter semantic tags
90
+ logger.debug(f"All tags in repository: {repo.tags}")
99
91
  tags = semsort([tag.name for tag in repo.tags])
100
92
  logger.debug(f"Sorted semantic tags: {tags}")
93
+
94
+ ### No tags case
101
95
  if tags:
102
96
  latest_tag = tags[0]
103
97
  logger.info(f"Latest semantic version tag: {latest_tag}")
104
98
  else:
105
- # No tags found, start with 0.0.0
106
- logger.info("No semantic version tags found. Starting with 0.0.0")
107
99
  latest_tag = '0.0.0'
100
+ logger.info("No semantic version tags found. Starting with 0.0.0")
108
101
 
109
- # Initialize obj
110
102
  current_version = SemanticVersion(latest_tag)
111
103
 
112
- ### Increment version ###
104
+ ### Increment version
113
105
  if args.major:
114
106
  logger.debug("Incrementing major version")
115
107
  current_version.inc_major(by=args.by)
@@ -120,7 +112,7 @@ Examples:
120
112
  logger.debug("Incrementing patch version")
121
113
  current_version.inc_patch(by=args.by)
122
114
 
123
- ### Label ###
115
+ ### Label
124
116
  if args.label:
125
117
  logger.debug(f"Adding label: {args.label}")
126
118
  current_version.add_label(args.label)
@@ -128,14 +120,18 @@ Examples:
128
120
  new_tag = str(current_version)
129
121
  logger.debug(f"Generated new tag: {new_tag}")
130
122
 
131
- ### Create and push
123
+ ### Create tag
132
124
  try:
133
- #TODO: add tag message option later
134
- #repo.create_tag(new_tag, message=f"Release {new_tag}")
135
- repo.create_tag(new_tag)
125
+ if args.msg:
126
+ logger.debug(f"Creating annotated tag '{new_tag}' with message: {args.msg}")
127
+ repo.create_tag(new_tag, message=args.msg)
128
+ else:
129
+ logger.debug(f"Creating lightweight tag '{new_tag}'")
130
+ repo.create_tag(new_tag)
131
+
136
132
  logger.info(f"Successfully created tag: {new_tag}")
137
133
 
138
- # Push if requested
134
+ ### Push
139
135
  if args.pushall:
140
136
  logger.debug("Pushing all local tags to remote...")
141
137
  repo.remote('origin').push(tags=True)
@@ -151,7 +147,7 @@ Examples:
151
147
  except Exception as e:
152
148
  logger.error(f"Error: {e}")
153
149
 
154
- # Print the new tag to stout as confirmation if not verbose
150
+ ### Print the new tag to stout as confirmation if not verbose
155
151
  if args.verbose == 0:
156
152
  GREEN = '\033[92m'
157
153
  YELLOW = '\033[93m'
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ # Pre-commit hook to generate README.md options from script argparse help
3
+
4
+ ### Install pre-commit hook:
5
+ # ln -s ../../tools/pre-commit .git/hooks/pre-commit
6
+
7
+ REPO_ROOT=$(git rev-parse --show-toplevel)
8
+
9
+ # Check if semtag.py has been modified
10
+ echo "Pre-commit hook running..."
11
+ if git diff --cached --name-only | grep -q semtag.py; then
12
+ echo "Updating README.md options..."
13
+ cd "$REPO_ROOT" || exit 1
14
+
15
+ OPTIONS_TMP=$(mktemp)
16
+ README_TMP=$(mktemp)
17
+
18
+ # Prefer virtual environment python if exists
19
+ if [ -d venv ];then
20
+ PYPATH="$REPO_ROOT/venv/bin/python"
21
+ else
22
+ PYPATH="python3"
23
+ fi
24
+
25
+ $PYPATH semtag.py --help 2>&1 | sed -n '/^options:/,/^$/p' | tail -n +2 > "$OPTIONS_TMP"
26
+
27
+ # README with updated options
28
+ awk -v opts_file="$OPTIONS_TMP" '
29
+ /<!-- OPTIONS:START -->/ { print; print "```"; system("cat " opts_file); print "```"; skip=1; next }
30
+ /<!-- OPTIONS:END -->/ { skip=0 }
31
+ !skip
32
+ ' README.md > "$README_TMP"
33
+
34
+ if [ $? -eq 0 ]; then
35
+ mv "$README_TMP" README.md
36
+ rm -f "$OPTIONS_TMP"
37
+ git add README.md
38
+ echo "README.md options updated and staged"
39
+ else
40
+ echo "Failed to update README.md"
41
+ rm -f "$README_TMP" "$OPTIONS_TMP"
42
+ exit 1
43
+ fi
44
+ fi
45
+
46
+ exit 0
@@ -1,49 +0,0 @@
1
- name: Publish to PyPI
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
- - '[0-9]+.[0-9]+.[0-9]+'
8
- - '[0-9]+.[0-9]+.[0-9]+-*'
9
-
10
- jobs:
11
- build-and-publish:
12
- runs-on: ubuntu-latest
13
- permissions:
14
- contents: write # Required for creating GitHub releases
15
- id-token: write # Required for trusted publishing
16
-
17
- steps:
18
- - name: Checkout code
19
- uses: actions/checkout@v4
20
- with:
21
- fetch-depth: 0 # Required for setuptools_scm to get git history
22
-
23
- - name: Set up Python
24
- uses: actions/setup-python@v5
25
- with:
26
- python-version: '3.x'
27
-
28
- - name: Install dependencies
29
- run: |
30
- python -m pip install --upgrade pip
31
- pip install build twine
32
-
33
- - name: Build package
34
- run: python -m build
35
-
36
- - name: Check package
37
- run: twine check dist/*
38
-
39
- # Use the official PyPI publish action
40
- - name: Publish to PyPI
41
- uses: pypa/gh-action-pypi-publish@release/v1
42
-
43
- # GH Release
44
- - name: Create GitHub Release
45
- uses: softprops/action-gh-release@v1
46
- with:
47
- generate_release_notes: true
48
- files: |
49
- dist/*
@@ -1 +0,0 @@
1
- gitpython>=3.1.0
File without changes
File without changes
File without changes
File without changes
File without changes