|
| 1 | +Re-usable GitHub Workflows |
| 2 | +========================== |
| 3 | + |
| 4 | +Replicate Commits to Version Branch |
| 5 | +----------------------------------- |
| 6 | + |
| 7 | +This re-usable workflow replicates commits from the ``master`` branch to a |
| 8 | +version branch. The version branch name is derived from the version of the |
| 9 | +Python package specified in the workflow. |
| 10 | + |
| 11 | +Version branches are essential during development to ensure that each |
| 12 | +OpenWISP module depends on compatible versions of its OpenWISP |
| 13 | +dependencies. Without version branches, modules depending on the |
| 14 | +``master`` branch of other modules may encounter errors, as the ``master`` |
| 15 | +branch could include future changes that are incompatible with previous |
| 16 | +versions. This makes it impossible to build a specific commit reliably |
| 17 | +after such changes. |
| 18 | + |
| 19 | +To address this, we use version branches so that each module can depend on |
| 20 | +a compatible version of its dependencies during development. Managing |
| 21 | +these version branches manually is time-consuming, which is why this |
| 22 | +re-usable GitHub workflow automates the process of keeping version |
| 23 | +branches synchronized with the ``master`` branch. |
| 24 | + |
| 25 | +You can invoke this workflow from another workflow using the following |
| 26 | +example: |
| 27 | + |
| 28 | +.. code-block:: yaml |
| 29 | +
|
| 30 | + name: Replicate Commits to Version Branch |
| 31 | +
|
| 32 | + on: |
| 33 | + push: |
| 34 | + branches: |
| 35 | + - master |
| 36 | +
|
| 37 | + jobs: |
| 38 | + version-branch: |
| 39 | + uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master |
| 40 | + with: |
| 41 | + # The name of the Python package (required) |
| 42 | + module_name: openwisp_utils |
| 43 | +
|
| 44 | +.. note:: |
| 45 | + |
| 46 | + If the ``master`` branch is force-pushed, this workflow will fail due |
| 47 | + to conflicts. To resolve this, you must manually synchronize the |
| 48 | + version branch with the ``master`` branch. You can use the following |
| 49 | + commands to perform this synchronization: |
| 50 | + |
| 51 | + .. code-block:: bash |
| 52 | +
|
| 53 | + VERSION=<enter-version-number> # e.g. 1.2 |
| 54 | + git fetch origin |
| 55 | + git checkout $VERSION |
| 56 | + git reset --hard origin/master |
| 57 | + git push origin $VERSION --force-with-lease |
0 commit comments