|
| 1 | +# Developing / maintaining the CFEngine CLI |
| 2 | + |
| 3 | +This document aims to have relevant information for people contributing to and maintaining the CFEngine CLI. |
| 4 | +It is not necessary for users of the tool to know about these processes. |
| 5 | +For general user information, see the [README](./README.md). |
| 6 | + |
| 7 | +## Releasing new versions |
| 8 | + |
| 9 | +Releases are [automated using a GH Action](https://github.com/cfengine/cfengine-cli/blob/main/.github/workflows/pypi-publish.yml) |
| 10 | +We create tags and releases through the GitHub UI. |
| 11 | +Go to the releases section in GitHub: |
| 12 | + |
| 13 | +https://github.com/cfengine/cfengine-cli/releases |
| 14 | + |
| 15 | +Determine the new version number according to SemVer: |
| 16 | + |
| 17 | +- Look at what is the latest released version. |
| 18 | +- Increase the first number if you are releasing breaking changes. |
| 19 | +- Or, increase the second number if there are new features (but no breaking changes). |
| 20 | +- Otherwise, increase the last number (only backwards compatible bugfixes). |
| 21 | + |
| 22 | +Sometimes, it's not 100% clear, so use your best judgement. |
| 23 | + |
| 24 | +Once you know the version number, proceed with making the release: |
| 25 | + |
| 26 | +1. Enter the version number into the **Choose a tag** dropdown. |
| 27 | +2. Click the **Create new tag on publish** alternative. |
| 28 | +3. Target should say **main**, don't change it. |
| 29 | +4. Put exactly the same version number into the **Release title** field. |
| 30 | +5. Click **Generate release notes**. |
| 31 | + - In general, it's not necessary to edit the release notes. |
| 32 | + - Sometimes you might want to add a link to a release blog post. |
| 33 | + - Or, if there is a lot of noise, for example changes to docs and tests which don't affect users, you can remove those. |
| 34 | +6. Leave the checkboxes below as is (latest release checked, pre-release unchecked). |
| 35 | +7. Click **Publish release**. |
| 36 | +8. Watch the release happen: |
| 37 | + - In GitHub Actions: https://github.com/cfengine/cfengine-cli/actions |
| 38 | + - And if all is well, the new version should appear on PyPI: https://pypi.org/project/cfengine/ |
| 39 | + |
| 40 | +If it does not work, click the failing GitHub Actions and try to understand what went wrong. |
| 41 | + |
| 42 | +## Rotating secrets |
| 43 | + |
| 44 | +The GH Action shown above requires a PyPI token to have access to publish new versions to PyPI. |
| 45 | +Sometimes, this needs to be rotated. |
| 46 | +[Log in](https://pypi.org/account/login/) to PyPI (need account access) and go to account settings: |
| 47 | + |
| 48 | +https://pypi.org/manage/account/ |
| 49 | + |
| 50 | +Delete the old `cfengine-cli` token and generate a new one with the same name and correct scope (only access to `cfengine` project). |
| 51 | +Copy the token and paste it into the GitHub Secret named `PYPI_PASSWORD`. |
| 52 | +`PYPI_USERNAME` should be there already, you don't have to edit it, it is simply `__token__`. |
| 53 | +Don't store the token anywhere else - we generate new tokens if necessary. |
| 54 | + |
| 55 | +## Code formatting |
| 56 | + |
| 57 | +We use automated code formatters to ensure consistent code style / indentation. |
| 58 | +Please format Python code with [black](https://pypi.org/project/black/), and YAML and markdown files with [Prettier](https://prettier.io/). |
| 59 | +For simplicity's sake, we don't have a custom configuration, we use the tool's defaults. |
| 60 | + |
| 61 | +If your editor does not do this automatically, you can run these tools from the command line: |
| 62 | + |
| 63 | +``` |
| 64 | +black . && prettier . --write |
| 65 | +``` |
0 commit comments