| 1 | --- |
| 2 | name: release |
| 3 | description: Guides the release of an Ansible collection following the upstream process (without release branches). Automatically determines the next version from changelog fragments. Outputs step-by-step instructions with commands for changelog generation, release PR, tagging, Galaxy publication, version bump, and GitHub release. Use when asked to release, publish, or tag a new collection version. |
| 4 | --- |
| 5 | |
| 6 | # Skill: release |
| 7 | |
| 8 | ## Purpose |
| 9 | |
| 10 | Guide the release of an Ansible collection. This skill is collection-generic — it derives namespace, name, and current version from `galaxy.yml`, and automatically determines the next version from changelog fragment categories. |
| 11 | |
| 12 | ## When to Invoke |
| 13 | |
| 14 | TRIGGER when: |
| 15 | - A user asks to release, publish, or tag a new collection version |
| 16 | - A user asks about the release process or release checklist |
| 17 | |
| 18 | DO NOT TRIGGER when: |
| 19 | - Reviewing a PR (use `pr-review` skill instead) |
| 20 | - Running tests (use `run-tests` skill instead) |
| 21 | - General changelog or versioning questions unrelated to performing a release |
| 22 | |
| 23 | ## Inputs |
| 24 | |
| 25 | - `version` (optional): the target release version, e.g. `2.1.0`. If not provided, the version is automatically determined from changelog fragments (see Step 1). |
| 26 | |
| 27 | ## Prerequisites |
| 28 | |
| 29 | - `antsibull-changelog` installed (`pip install antsibull-changelog`) |
| 30 | - `gh` CLI installed and authenticated |
| 31 | - Push access to the upstream remote |
| 32 | |
| 33 | ## Human Confirmation Gates |
| 34 | |
| 35 | **Do not proceed past a confirmation gate without explicit human approval.** Present the relevant information and wait for the human to confirm before continuing to the next step. Gates are marked with **CONFIRM** below. |
| 36 | |
| 37 | ## Release Steps |
| 38 | |
| 39 | ### Step 1 — Read collection context and determine version |
| 40 | |
| 41 | Extract collection identity from `galaxy.yml`: |
| 42 | |
| 43 | ```bash |
| 44 | grep -E '^(namespace|name|version):' galaxy.yml |
| 45 | ``` |
| 46 | |
| 47 | Use the extracted values as `NAMESPACE`, `COLLECTION`, and `CURRENT_VERSION` in all subsequent steps. |
| 48 | |
| 49 | #### Determine next version |
| 50 | |
| 51 | If the user did not provide a target version, determine it automatically: |
| 52 | |
| 53 | 1. Scan all YAML files in `changelogs/fragments/` and collect the top-level keys (category names) from each file. |
| 54 | 2. Determine the version bump using the highest-severity category found: |
| 55 | |
| 56 | | Bump | Fragment categories | |
| 57 | |-------|----------------------------------------------------------| |
| 58 | | Major | `breaking_changes`, `removed_features`, `major_changes` | |
| 59 | | Minor | `minor_changes`, `deprecated_features` | |
| 60 | | Patch | `bugfixes`, `security_fixes`, `known_issues`, `trivial` | |
| 61 | |
| 62 | 3. Apply the bump to `CURRENT_VERSION` (e.g. `2.0.0` + minor → `2.1.0`). When bumping major, reset minor and patch to 0. When bumping minor, reset patch to 0. |
| 63 | |
| 64 | Use the resulting version as `VERSION`. |
| 65 | |
| 66 | **CONFIRM:** Present the extracted `NAMESPACE`, `COLLECTION`, `CURRENT_VERSION`, the detected fragment categories, the determined bump type, and the resulting `VERSION` to the human. Ask them to confirm these values are correct before proceeding. The human may override the version at this point. |
| 67 | |
| 68 | ### Step 2 — Pre-flight checks |
| 69 | |
| 70 | ```bash |
| 71 | git status |
| 72 | git checkout main |
| 73 | git pull --rebase upstream main |
| 74 | ``` |
| 75 | |
| 76 | Verify before continuing: |
| 77 | - Working tree is clean (no uncommitted changes) |
| 78 | - Changelog fragments exist: `ls changelogs/fragments/` |
| 79 | |
| 80 | ### Step 3 — Update galaxy.yml version |
| 81 | |
| 82 | If `CURRENT_VERSION` in `galaxy.yml` does not match `VERSION`, update it: |
| 83 | |
| 84 | ```bash |
| 85 | sed -i "s/^version: .*/version: VERSION/" galaxy.yml |
| 86 | ``` |
| 87 | |
| 88 | ### Step 4 — Create release branch |
| 89 | |
| 90 | ```bash |
| 91 | git checkout -b release_VERSION |
| 92 | ``` |
| 93 | |
| 94 | ### Step 5 — Generate changelog |
| 95 | |
| 96 | Determine the release type from `VERSION` and suggest a release summary using this template: |
| 97 | |
| 98 | - **Major** (`X.0.0`): `This is a major release of the ``NAMESPACE.COLLECTION`` collection.` |
| 99 | - **Minor** (`X.Y.0`): `This is a minor release of the ``NAMESPACE.COLLECTION`` collection.` |
| 100 | - **Patch** (`X.Y.Z`): `This is a patch release of the ``NAMESPACE.COLLECTION`` collection.` |
| 101 | |
| 102 | Followed by: |
| 103 | `This changelog contains all changes to the modules and plugins in this collection that have been made after the previous release.` |
| 104 | |
| 105 | **CONFIRM:** Present the suggested release summary and the list of changelog fragments that will be included. Ask the human to approve or edit the text before writing the fragment. |
| 106 | |
| 107 | Create the release summary fragment: |
| 108 | |
| 109 | ```bash |
| 110 | cat > changelogs/fragments/VERSION.yml << 'EOF' |
| 111 | release_summary: |- |
| 112 | This is a <major/minor/patch> release of the ``NAMESPACE.COLLECTION`` collection. |
| 113 | This changelog contains all changes to the modules and plugins in this collection |
| 114 | that have been made after the previous release. |
| 115 | EOF |
| 116 | ``` |
| 117 | |
| 118 | Generate the changelog: |
| 119 | |
| 120 | ```bash |
| 121 | antsibull-changelog release --reload-plugins |
| 122 | ``` |
| 123 | |
| 124 | **CONFIRM:** Show the human the generated `CHANGELOG.rst` diff and ask them to confirm the content is correct before continuing. |
| 125 | |
| 126 | ### Step 6 — Commit and push release branch |
| 127 | |
| 128 | ```bash |
| 129 | git add -A |
| 130 | git commit -m "Release VERSION" |
| 131 | git push origin release_VERSION |
| 132 | ``` |
| 133 | |
| 134 | ### Step 7 — Create pull request |
| 135 | |
| 136 | ```bash |
| 137 | gh pr create --title "Release VERSION" --body "Release VERSION of NAMESPACE.COLLECTION." |
| 138 | ``` |
| 139 | |
| 140 | **CONFIRM:** Wait for the human to confirm that CI has passed and the PR has been reviewed and merged before continuing. |
| 141 | |
| 142 | ### Step 8 — Update local main |
| 143 | |
| 144 | After the PR is merged: |
| 145 | |
| 146 | ```bash |
| 147 | git checkout main |
| 148 | git pull --rebase upstream main |
| 149 | ``` |
| 150 | |
| 151 | ### Step 9 — Tag and push |
| 152 | |
| 153 | **CONFIRM:** Ask the human to confirm before creating and pushing the tag. This action is irreversible. |
| 154 | |
| 155 | ```bash |
| 156 | git tag -a VERSION -m "NAMESPACE.COLLECTION: VERSION" |
| 157 | git push upstream VERSION |
| 158 | ``` |
| 159 | |
| 160 | ### Step 10 — Create GitHub release |
| 161 | |
| 162 | ```bash |
| 163 | gh release create VERSION --title "VERSION" --notes "See [CHANGELOG.rst](https://github.com/NAMESPACE/COLLECTION/blob/main/CHANGELOG.rst) for details." |
| 164 | ``` |
| 165 | |
| 166 | ## Output Format |
| 167 | |
| 168 | Present each step as a numbered section containing: |
| 169 | 1. What the step does (one line) |
| 170 | 2. The exact command(s) to run (with placeholders replaced by actual values) |
| 171 | 3. What to verify before proceeding to the next step |