Skip to content

Commit

Permalink
Add a workflow which automatically adds backport tags based upon chan…
Browse files Browse the repository at this point in the history
…gelogs (#2454)

##### SUMMARY

As has been recently noticed, we're being inconsistent with backporting things.

Based on the keys from the changelog fragments this action would perform the following actions:

- On "push" or applying the `mergeit` label
  -  If a PR contains **non-backportable** changes (`major_changes`, `breaking_changes`, `removed_features`) the `do_not_backport` label will be applied.  These change types are assumed to require a "major" release, and as such shouldn't be backported into a currently "stable" release.  At the same time it will remove any previously applied `backport-*` labels.
- When the "mergeit" label is applied:
  - If a PR contains changes that only need a **minor release** (minor_changes, deprecated_features) the `backport-9` label will be applied.
  - If a PR contains changes that only need a **patch release**, such as security/bug fixes (bugfixes, security_fixes), then `backport-8` and `backport-9` labels will both be applied.

##### ISSUE TYPE

- Feature Pull Request

##### COMPONENT NAME

.github/workflows

##### ADDITIONAL INFORMATION
  • Loading branch information
tremble authored Jan 14, 2025
1 parent 9ae20ab commit 429cff0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/backports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: mergeit-backport

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
types:
- labeled
- opened
- synchronize
branches:
- main

jobs:
changelog-labeller:
uses: ansible-network/github_actions/.github/workflows/backport-labeller.yml@main
with:
label_minor_release: backport-9
label_bugfix_release: backport-8
38 changes: 31 additions & 7 deletions docs/docsite/rst/collection_release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ Ensure that your local copy of the ``main`` branch is up to date and contains al
Preparing a new stable branch
-----------------------------

.. warning::
Zuul will need updating here too.

As part of the next release cycle please add an entry here about configuring the Zuul sanity jobs
for the new stable-6 branch.

Create and push a new ``stable-<major-version>`` branch (for example ``stable-6`` for release
``6.0.0``):

Expand All @@ -108,6 +102,14 @@ Create and push a new ``stable-<major-version>`` branch (for example ``stable-6`
git checkout -b stable-6
git push --set-upstream origin stable-6
Create a new label ``backport-<major-version>`` (for example ``backport-6`` for release ``6.0.0``).
This can either be done through the `GitHub UI <https://github.com/ansible-collections/amazon.aws/labels>`_
or using the GH CLI if you have it installed and configured:

.. code-block:: bash
gh label create backport-6 -c FFAA22 --description "PR should be backported to the stable-6 branch" -R ansible-collections/amazon.aws
Create a pull request against the new branch updating any documentation links from ``main`` to the
new ``stable-<major-version>`` branch.

Expand All @@ -121,18 +123,40 @@ Now that our new major release has been branched, we update the ``main`` branch
configured as the pre-release development version for the **next** release (for example
``7.0.0-dev0`` if you're preparing ``6.0.0``).

Create a pull request against the ``main`` branch that updates the
`backport-labeller workflow <https://github.com/ansible-collections/amazon.aws/tree/main/.github/workflows/backports.yml>`_
so that non-breaking changes will automatically be backported to the new branch:

.. code-block:: yaml
---
name: mergeit-backport
...
jobs:
changelog-labeller:
uses: ansible-network/github_actions/.github/workflows/backport-labeller.yml@main
with:
label_minor_release: backport-6
label_bugfix_release: backport-5
Create a pull request against the ``main`` branch updating the
`galaxy.yml <https://github.com/ansible-collections/amazon.aws/blob/main/galaxy.yml>`_ version
information and the `plugins/module_utils/common.py
<https://github.com/ansible-collections/amazon.aws/blob/main/plugins/module_utils/common.py>`_
version information to a ``dev0`` prerelease of the next major release. This may result in deprecation
errors from the sanity tests. Create issues and add entries to the relevant
`sanity test ignore files <https://github.com/ansible-collections/amazon.aws/tree/main/tests/sanity>`_.
(including a link to the issue)
(including a link to the issue).

For an example pull request see
`ansible-collections/amazon.aws#1108 <https://github.com/ansible-collections/amazon.aws/pull/1108>`_

(In theory both steps can be done with a single PR. However, the bot performing our automatic
merges will refuse to merge PRs which make changes to the contents of .github. Splitting the PRs up
reduces the scope of the manually merged PR.)

Next steps
----------
Expand Down

0 comments on commit 429cff0

Please sign in to comment.