|
| 1 | +# Tag Manager |
| 2 | + |
| 3 | +A generic CLI tool for managing version tags across multiple Go repositories. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Generic Package Discovery**: Automatically discovers Go packages across multiple repositories |
| 8 | +- **Custom Tag Naming**: Support for custom tag naming conventions via configuration |
| 9 | +- **Interactive Setup**: Guided configuration for new packages with sensible defaults |
| 10 | +- **Version Management**: Support for major, minor, and patch version updates |
| 11 | +- **Configuration Persistence**: Remembers your tag naming preferences |
| 12 | +- **Multi-Repository Support**: Works across any number of Go repositories |
| 13 | +- **Git Integration**: Automatic tag creation and pushing |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +1. Navigate to the tag-manager directory: |
| 18 | + ```bash |
| 19 | + cd tag-manager |
| 20 | + ``` |
| 21 | + |
| 22 | +2. Install dependencies: |
| 23 | + ```bash |
| 24 | + go mod tidy |
| 25 | + ``` |
| 26 | + |
| 27 | +3. Build the application: |
| 28 | + ```bash |
| 29 | + go build -o tag-manager |
| 30 | + ``` |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +### List discovered packages |
| 35 | + |
| 36 | +```bash |
| 37 | +./tag-manager list |
| 38 | +``` |
| 39 | + |
| 40 | +This command will scan for Go modules in the current directory and its subdirectories, displaying all discovered packages. |
| 41 | + |
| 42 | +### Update a package tag |
| 43 | + |
| 44 | +```bash |
| 45 | +./tag-manager update |
| 46 | +``` |
| 47 | + |
| 48 | +The tool will guide you through the entire process interactively: |
| 49 | +1. **Package Discovery**: Automatically scan for Go packages in the current directory and its subdirectories |
| 50 | +2. **Package Selection**: Choose from the discovered packages |
| 51 | +3. **Configuration Setup**: Configure tag naming convention (first time only) |
| 52 | +4. **Version Selection**: Choose version type (major/minor/patch) |
| 53 | +5. **Confirmation**: Review and confirm the tag update |
| 54 | + |
| 55 | +### Examples |
| 56 | + |
| 57 | +**First-time setup for a package:** |
| 58 | +```bash |
| 59 | +./tag-manager update |
| 60 | +# 1. Select package from discovered list |
| 61 | +# 2. Choose tag format (default or custom) |
| 62 | +# 3. Select version type |
| 63 | +# 4. Confirm tag creation |
| 64 | +``` |
| 65 | + |
| 66 | +**Subsequent updates:** |
| 67 | +```bash |
| 68 | +./tag-manager update |
| 69 | +# 1. Select package (configuration remembered) |
| 70 | +# 2. Select version type |
| 71 | +# 3. Confirm tag creation |
| 72 | +``` |
| 73 | + |
| 74 | +### Configuration |
| 75 | + |
| 76 | +The tool uses a configuration file (`~/.tag-manager.yaml`) to store package-specific settings: |
| 77 | + |
| 78 | +- **Tag Format**: Custom tag naming conventions per package |
| 79 | +- **Repository Mapping**: Links packages to their repositories |
| 80 | +- **Default Settings**: Global defaults for new packages |
| 81 | + |
| 82 | +**Default Tag Format**: `{package-name}/v{major}.{minor}.{patch}` |
| 83 | + |
| 84 | +**Custom Format Examples**: |
| 85 | +- `{package-name}-v{major}.{minor}.{patch}` |
| 86 | +- `v{major}.{minor}.{patch}` |
| 87 | +- `{package-name}/{major}.{minor}.{patch}` |
| 88 | + |
| 89 | +### Version Types |
| 90 | + |
| 91 | +- `major`: Increments the major version (e.g., v1.2.3 → v2.0.0) |
| 92 | +- `minor`: Increments the minor version (e.g., v1.2.3 → v1.3.0) |
| 93 | +- `patch`: Increments the patch version (e.g., v1.2.3 → v1.2.4) |
| 94 | + |
| 95 | +## Using Makefile |
| 96 | + |
| 97 | +You can also use the provided Makefile for easier management: |
| 98 | + |
| 99 | +```bash |
| 100 | +# Build the application |
| 101 | +make build |
| 102 | + |
| 103 | +# Run the tag manager |
| 104 | +make run |
| 105 | + |
| 106 | +# Clean build artifacts |
| 107 | +make clean |
| 108 | +``` |
| 109 | + |
| 110 | +**Note**: For the best interactive experience, run the command directly: |
| 111 | +```bash |
| 112 | +./tag-manager update |
| 113 | +``` |
| 114 | + |
| 115 | +# Clean build artifacts |
| 116 | +make clean |
| 117 | +``` |
| 118 | +
|
| 119 | +## How it works |
| 120 | +
|
| 121 | +1. **Package Discovery**: Scans the current directory and its subdirectories for `go.mod` files to discover Go packages |
| 122 | +2. **Package Selection**: User selects from discovered packages |
| 123 | +3. **Configuration Check**: Checks if package has custom tag format configuration |
| 124 | +4. **Interactive Setup**: For new packages, guides user through tag format configuration |
| 125 | +5. **Version Selection**: User chooses version type (major/minor/patch) |
| 126 | +6. **Tag Calculation**: Calculates new version based on current tag and selected type |
| 127 | +7. **Confirmation**: Shows current and new tags for user confirmation |
| 128 | +8. **Git Operations**: Creates and pushes the new git tag |
| 129 | +
|
| 130 | +## Tag Format |
| 131 | +
|
| 132 | +The tool supports flexible tag formats through configuration: |
| 133 | +
|
| 134 | +**Default Format**: `{package-name}/v{major}.{minor}.{patch}` |
| 135 | +
|
| 136 | +**Examples**: |
| 137 | +- `utils/v1.2.3` |
| 138 | +- `authorization/v0.1.0` |
| 139 | +- `cache/v2.0.0` |
| 140 | +
|
| 141 | +**Custom Formats**: |
| 142 | +- `utils-v1.2.3` (using `{package-name}-v{major}.{minor}.{patch}`) |
| 143 | +- `v1.2.3` (using `v{major}.{minor}.{patch}`) |
| 144 | +- `utils/1.2.3` (using `{package-name}/{major}.{minor}.{patch}`) |
| 145 | +
|
| 146 | +## Configuration File |
| 147 | +
|
| 148 | +The tool creates a configuration file at `~/.tag-manager.yaml` to store your preferences: |
| 149 | +
|
| 150 | +```yaml |
| 151 | +packages: |
| 152 | + github.com/example/package: |
| 153 | + module_path: github.com/example/package |
| 154 | + tag_format: "{package-name}/v{major}.{minor}.{patch}" |
| 155 | + repository: example-repo |
| 156 | + use_default: true |
| 157 | + last_updated: "2024-01-01T00:00:00Z" |
| 158 | +defaults: |
| 159 | + tag_format: "{package-name}/v{major}.{minor}.{patch}" |
| 160 | +``` |
0 commit comments