|
1 | 1 | arduino-release
|
2 |
| -=============== |
| 2 | +=============== |
| 3 | + |
| 4 | +The ``arduino-release`` script is an utility for managing semantic versioning releases of Arduino assets (libraries and cores). It supports with the automation of the entire release process including version validation, CI workflow verification, git tagging, and library.properties file management. |
| 5 | + |
| 6 | +Overview |
| 7 | +-------- |
| 8 | + |
| 9 | +This tool provides a complete solution for releasing Arduino projects following semantic versioning (semver) best practices. It integrates with GitHub Actions to ensure all CI workflows pass before creating releases, maintains proper version consistency across different files, and automates git operations. |
| 10 | + |
| 11 | +The script supports both **Arduino libraries** and **Arduino cores**, automatically detecting the asset type and applying the appropriate release workflow. |
| 12 | + |
| 13 | +Features |
| 14 | +-------- |
| 15 | + |
| 16 | +- **Semantic versioning support**: Full semver compliance with validation |
| 17 | +- **CI/CD integration**: Verifies GitHub Actions workflows before release |
| 18 | +- **Automatic version bumping**: Supports major, minor, and patch increments |
| 19 | +- **library.properties management**: Automatically updates version for libraries |
| 20 | +- **Git automation**: Handles tagging, committing, and pushing |
| 21 | +- **Branch protection**: Ensures releases only from main/master branches |
| 22 | +- **Release verification**: Post-release validation capabilities |
| 23 | +- **Asset type detection**: Automatically identifies libraries vs cores |
| 24 | + |
| 25 | +Supported asset types |
| 26 | +--------------------- |
| 27 | + |
| 28 | +**Arduino libraries:** |
| 29 | + - Detected by presence of ``library.properties`` file |
| 30 | + - Automatically updates version field in ``library.properties`` |
| 31 | + - Creates commit for version change before tagging |
| 32 | + |
| 33 | +**Arduino cores:** |
| 34 | + - Detected by presence of ``platform.txt``, ``boards.txt``, ``cores/``, and ``variants/`` |
| 35 | + - Only performs git tagging (no file modifications needed) |
| 36 | + |
| 37 | +Usage |
| 38 | +----- |
| 39 | + |
| 40 | +The script provides three main subcommands: |
| 41 | + |
| 42 | +.. code:: bash |
| 43 | +
|
| 44 | + python arduino-release.py <command> [options] |
| 45 | +
|
| 46 | +Commands |
| 47 | +^^^^^^^^ |
| 48 | + |
| 49 | +**new** |
| 50 | + Create a new release with version validation and CI checks. |
| 51 | + |
| 52 | +**verify** |
| 53 | + Verify that all requirements are met for an existing release. |
| 54 | + |
| 55 | +**info** |
| 56 | + Display information about the current repository state. |
| 57 | + |
| 58 | +Basic examples |
| 59 | +^^^^^^^^^^^^^^ |
| 60 | + |
| 61 | +Create a new patch release: |
| 62 | + |
| 63 | +.. code:: bash |
| 64 | +
|
| 65 | + python arduino-release.py new patch |
| 66 | +
|
| 67 | +Create a new minor release: |
| 68 | + |
| 69 | +.. code:: bash |
| 70 | +
|
| 71 | + python arduino-release.py new minor |
| 72 | +
|
| 73 | +Create a new major release: |
| 74 | + |
| 75 | +.. code:: bash |
| 76 | +
|
| 77 | + python arduino-release.py new major |
| 78 | +
|
| 79 | +Create a specific version release: |
| 80 | + |
| 81 | +.. code:: bash |
| 82 | +
|
| 83 | + python arduino-release.py new 2.1.0 |
| 84 | +
|
| 85 | +Verify an existing release: |
| 86 | + |
| 87 | +.. code:: bash |
| 88 | +
|
| 89 | + python arduino-release.py verify |
| 90 | +
|
| 91 | +Get repository information: |
| 92 | + |
| 93 | +.. code:: bash |
| 94 | +
|
| 95 | + python arduino-release.py info head-tag |
| 96 | + python arduino-release.py info repo-name |
| 97 | + python arduino-release.py info asset-type |
| 98 | +
|
| 99 | +Detailed command reference |
| 100 | +-------------------------- |
| 101 | + |
| 102 | +new |
| 103 | +^^^ |
| 104 | + |
| 105 | +Creates a new release for the specified version. |
| 106 | + |
| 107 | +**Syntax:** |
| 108 | + |
| 109 | +.. code:: bash |
| 110 | +
|
| 111 | + python arduino-release.py new <version> [options] |
| 112 | +
|
| 113 | +**Arguments:** |
| 114 | + |
| 115 | +``version`` |
| 116 | + The new version to create. Can be: |
| 117 | + |
| 118 | + - **Bump type**: ``major``, ``minor``, or ``patch`` |
| 119 | + - **Specific version**: Semver format like ``1.2.3``, ``2.0.0-rc.1`` |
| 120 | + |
| 121 | +**Options:** |
| 122 | + |
| 123 | +``--root-path <path>`` |
| 124 | + Path to the Arduino asset root directory. |
| 125 | + |
| 126 | + **Default**: Current working directory |
| 127 | + |
| 128 | +``--any-branch`` |
| 129 | + Allow releases from any branch (bypasses main/master requirement). |
| 130 | + |
| 131 | + **Default**: false (releases only from main/master) |
| 132 | + |
| 133 | +**Process flow:** |
| 134 | + |
| 135 | +1. **Branch validation**: Ensures HEAD is on main/master branch |
| 136 | +2. **CI verification**: Waits for and validates all GitHub Actions workflows |
| 137 | +3. **Tag check**: Ensures HEAD is not already tagged |
| 138 | +4. **Version calculation**: Determines new version from current tags |
| 139 | +5. **Version validation**: Validates semver compliance and proper increment |
| 140 | +6. **File updates**: For libraries, updates ``library.properties`` |
| 141 | +7. **Git operations**: Creates commit (if needed), tag, and pushes to remote |
| 142 | + |
| 143 | +**Example process output:** |
| 144 | + |
| 145 | +.. code:: text |
| 146 | +
|
| 147 | + --> Checking if repo HEAD in the default branch... [OK] |
| 148 | + --> Waiting for all ci workflows completion for HEAD... [OK] |
| 149 | + --> Checking if HEAD is not already tagged... [OK] |
| 150 | + --> Previous last version: 1.2.0 |
| 151 | + --> New bumped version: 1.3.0 |
| 152 | + --> Updating "library.properties" file with new version... [OK] |
| 153 | + --> Committing changes to library.properties file... [OK] |
| 154 | + --> Creating new git tag... [OK] |
| 155 | + --> Pushing new git tag... [OK] |
| 156 | +
|
| 157 | +verify |
| 158 | +^^^^^^ |
| 159 | + |
| 160 | +Verifies that all requirements are met for an existing release. |
| 161 | + |
| 162 | +**Syntax:** |
| 163 | + |
| 164 | +.. code:: bash |
| 165 | +
|
| 166 | + python arduino-release.py verify [options] |
| 167 | +
|
| 168 | +**Validation checks:** |
| 169 | + |
| 170 | +1. **CI workflows**: All GitHub Actions workflows must be successful |
| 171 | +2. **Version validity**: Current tag must be valid semver increment from previous |
| 172 | +3. **File consistency**: For libraries, ``library.properties`` version must match git tag |
| 173 | + |
| 174 | +**Use cases:** |
| 175 | +- Post-release validation in CI/CD pipelines |
| 176 | +- Troubleshooting release issues |
| 177 | +- Ensuring release integrity |
| 178 | + |
| 179 | +info |
| 180 | +^^^^ |
| 181 | + |
| 182 | +Displays information about the current repository state. |
| 183 | + |
| 184 | +**Syntax:** |
| 185 | + |
| 186 | +.. code:: bash |
| 187 | +
|
| 188 | + python arduino-release.py info <key> [options] |
| 189 | +
|
| 190 | +**Available keys:** |
| 191 | + |
| 192 | +``head-tag`` |
| 193 | + Shows the git tag of the current HEAD commit. |
| 194 | + |
| 195 | +``repo-name`` |
| 196 | + Shows the repository name (without owner). |
| 197 | + |
| 198 | +``asset-type`` |
| 199 | + Shows whether the asset is a "library" or "core". |
| 200 | + |
| 201 | +**Examples:** |
| 202 | + |
| 203 | +.. code:: bash |
| 204 | +
|
| 205 | + $ python arduino-release.py info head-tag |
| 206 | + 1.2.3 |
| 207 | + |
| 208 | + $ python arduino-release.py info asset-type |
| 209 | + library |
| 210 | +
|
| 211 | +Version management |
| 212 | +------------------ |
| 213 | + |
| 214 | +Semantic versioning rules |
| 215 | +^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 216 | + |
| 217 | +The script enforces strict semantic versioning rules: |
| 218 | + |
| 219 | +**Major version (X.0.0):** |
| 220 | +- Breaking changes |
| 221 | +- Minor and patch must be 0 |
| 222 | +- Can only increment by 1 |
| 223 | + |
| 224 | +**Minor version (0.X.0):** |
| 225 | +- New features, backward compatible |
| 226 | +- Patch must be 0 |
| 227 | +- Major stays the same, minor increments by 1 |
| 228 | + |
| 229 | +**Patch version (0.0.X):** |
| 230 | +- Bug fixes, backward compatible |
| 231 | +- Major and minor stay the same, patch increments by 1 |
| 232 | + |
| 233 | +**Pre-release support:** |
| 234 | +- Supports release candidates: ``1.0.0-rc.1`` |
| 235 | +- Can release final version from RC: ``1.0.0-rc.1`` → ``1.0.0`` |
| 236 | + |
| 237 | +Version bump examples |
| 238 | +^^^^^^^^^^^^^^^^^^^^^ |
| 239 | + |
| 240 | +.. code:: bash |
| 241 | +
|
| 242 | + # From 1.2.3 to 1.2.4 (patch) |
| 243 | + python arduino-release.py new patch |
| 244 | + |
| 245 | + # From 1.2.3 to 1.3.0 (minor) |
| 246 | + python arduino-release.py new minor |
| 247 | + |
| 248 | + # From 1.2.3 to 2.0.0 (major) |
| 249 | + python arduino-release.py new major |
| 250 | + |
| 251 | + # Specific version |
| 252 | + python arduino-release.py new 1.5.0 |
| 253 | +
|
| 254 | +CI/CD integration |
| 255 | +----------------- |
| 256 | + |
| 257 | +GitHub actions integration |
| 258 | +^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 259 | + |
| 260 | +The script integrates deeply with GitHub Actions: |
| 261 | + |
| 262 | +1. **Workflow Detection**: Automatically finds all workflows for the HEAD commit |
| 263 | +2. **Status monitoring**: Waits for in-progress workflows to complete |
| 264 | +3. **Success validation**: Ensures all workflows pass before proceeding |
| 265 | +4. **Release workflow Skip**: Ignores workflows containing "release" in the name |
| 266 | + |
| 267 | +**Workflow status handling:** |
| 268 | + |
| 269 | +- ``in_progress`` / ``requested``: Waits with progress animation |
| 270 | +- ``success``: Continues with release process |
| 271 | +- ``failure``: Stops and exits with error |
| 272 | + |
| 273 | +**API requirements:** |
| 274 | + |
| 275 | +- Uses GitHub REST API (no authentication required for public repos) |
| 276 | +- Requires internet connection |
| 277 | +- Works with both public and private repositories |
| 278 | + |
| 279 | +Prerequisites |
| 280 | +------------- |
| 281 | + |
| 282 | +**System requirements:** |
| 283 | +- Python 3.x with required packages: ``requests``, ``semver`` |
| 284 | +- Git installed and configured |
| 285 | +- Internet connection for GitHub API access |
| 286 | + |
| 287 | +**Repository requirements:** |
| 288 | +- Git repository with GitHub remote (https or ssh) |
| 289 | +- At least one existing commit |
| 290 | +- For libraries: valid ``library.properties`` file |
| 291 | +- For cores: valid ``platform.txt``, ``boards.txt``, ``cores/``, ``variants/`` |
| 292 | + |
| 293 | +**Git configuration:** |
| 294 | +- Git user.name and user.email configured (or will be set to GitHub Actions bot) |
| 295 | +- Push permissions to the remote repository |
| 296 | +- Proper authentication for git push operations |
| 297 | + |
| 298 | +Error handling |
| 299 | +-------------- |
| 300 | + |
| 301 | +The script provides comprehensive error handling with detailed messages: |
| 302 | + |
| 303 | +**Common errors:** |
| 304 | + |
| 305 | +``Release is allowed only from permanent branches`` |
| 306 | + Solution: Switch to main/master branch or use ``--any-branch`` |
| 307 | + |
| 308 | +``This HEAD is already tagged`` |
| 309 | + Solution: Make new commits or use existing tag for verification |
| 310 | + |
| 311 | +``The new version is not a valid semver increment`` |
| 312 | + Solution: Check version rules and use proper semver increments |
| 313 | + |
| 314 | +``All CI workflows must be successful`` |
| 315 | + Solution: Fix failing workflows before creating release |
| 316 | + |
| 317 | +``Package index file not found`` |
| 318 | + Solution: Ensure proper Arduino asset structure |
| 319 | + |
| 320 | +**Exit codes:** |
| 321 | +- ``0``: Success |
| 322 | +- ``1``: Error occurred (check error message for details) |
| 323 | + |
| 324 | +Advanced usage |
| 325 | +-------------- |
| 326 | + |
| 327 | +**Release from feature branch:** |
| 328 | + |
| 329 | +.. code:: bash |
| 330 | +
|
| 331 | + # Allow releases from any branch (use with caution) |
| 332 | + python arduino-release.py new patch --any-branch |
| 333 | +
|
| 334 | +**Custom root directory:** |
| 335 | + |
| 336 | +.. code:: bash |
| 337 | +
|
| 338 | + # Release from specific directory |
| 339 | + python arduino-release.py new minor --root-path /path/to/arduino/project |
| 340 | +
|
| 341 | +**CI/CD pipeline integration:** |
| 342 | + |
| 343 | +.. code:: yaml |
| 344 | +
|
| 345 | + # GitHub Actions workflow example |
| 346 | + - name: Create Release |
| 347 | + run: | |
| 348 | + python arduino-release.py new patch |
| 349 | + |
| 350 | + - name: Verify Release |
| 351 | + run: | |
| 352 | + python arduino-release.py verify |
| 353 | +
|
| 354 | +**Batch operations:** |
| 355 | + |
| 356 | +.. code:: bash |
| 357 | +
|
| 358 | + # Get current version for other scripts |
| 359 | + CURRENT_VERSION=$(python arduino-release.py info head-tag) |
| 360 | + echo "Current version: $CURRENT_VERSION" |
| 361 | +
|
| 362 | +Best practices |
| 363 | +-------------- |
| 364 | + |
| 365 | +1. **Always run from main/master**: Use default branch protection unless absolutely necessary |
| 366 | +2. **Verify CI first**: Ensure all tests pass before creating releases |
| 367 | +3. **Use semantic versioning**: Follow semver rules for version increments |
| 368 | +4. **Test releases**: Use the verify command to validate releases |
| 369 | +5. **Automate in CI**: Integrate into GitHub Actions for consistent releases |
| 370 | +6. **Backup important work**: Script modifies git history and files |
| 371 | + |
| 372 | +.. warning:: |
| 373 | + This script performs git operations including creating commits, tags, and pushing to remote repositories. Always ensure your work is backed up and you have proper permissions before running. |
| 374 | + |
| 375 | +.. tip:: |
| 376 | + Use the ``--any-branch`` flag carefully in development environments. For production releases, always use the default main/master branch requirement. |
0 commit comments